0

I need to query the Fields highlight in the below snapshot is there any way to query them through tooling API/Rest/SOAP?

Usecase: I need to know who created the custom fields last month. enter image description here

1
  • Would need more clarity to your question, like: code snippets trying to make the callout, apex controllers. As of now, the question is too barren to give answers for.
    – NedlaV
    Jul 20, 2023 at 14:58

2 Answers 2

2

You could query CustomField object with Tooling API:

SELECT Id, DeveloperName, CreatedDate, CreatedBy.Name, LastModifiedDate, LastModifiedBy.Name
FROM CustomField
WHERE EntityDefinition.DeveloperName = 'Opportunity' AND DeveloperName = 'ARR'

FieldDefinition has no CreatedDate field.

Please note that DeveloperName in both CustomField and FieldDefinition object doesn't include the __c suffix, indeed the developerName of your custom field is just ARR.

1
1

In order to obtain CreatedBy and LastModifiedBy values you could use CustomObject and CustomField objects exposed by Tooling API

For instance this query:

Select Id, TableEnumOrId, DeveloperName, CreatedBy.Name, LastModifiedBy.Name, LastModifiedDate, CreatedDate from CustomField

Will give you:

Id - field Id TableEnumOrId - object Name or Id (if it is custom object)
DeveloperName - field name
CreatedBy.Name - name of user who created the field

  • CreatedBy.Id will give you Id if user who created the field

LastModifiedBy.Name - name of user who last modified the field
LastModifiedDate - date when field was last modified CreatedDate - date when field was created

The easiest way to obtain this data would probably be via a Tooling API query from Developer Console of (if needs to be automated) via sfdx cli.
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_data.htm

If you have to query the above data from Apex, then you could leverage Apex Tooling API library https://github.com/afawcett/apex-toolingapi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .