function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gauri GaikwadGauri Gaikwad 

How to Query audit fields in SOQL query?

Hi,

i have created a custom object say 'test__c' and i writing a query to get the 'created date field'.

But m getting the error as


"select CreatedBy from test__c
ERROR at Row:1:Column:8
No such column 'CreatedBy' on entity 'test__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."

 

I want to do delete opertaion based upon time given in createdBy field.

Cant we include audit fields in SOQL query?

ALso i cant see 'Created Date' field in my custom object.

 

Any Help..!

Thanks..!

 

Vinita_SFDCVinita_SFDC

Hello,

 

There is no standard field with the name CreatedBy, that is why you are getting this error. Try this:

 

SELECT CreatedById,CreatedDate FROM test__c