Reputation: 550
When using Salesforce's SObject Describe endpoint, I see a ton of metadata about an object's fields. But the property that is missing for every field is its ID.
I want to be able to track when a custom field has been changed, including when it has been renamed. So, using the field's name
attribute won't suffice. I need some kind of unique identifier.
Naturally, I can see the ID of a custom field in the URL bar when editing the field:
https://my-org.lightning.force.com/lightning/setup/ObjectManager/Contact/FieldsAndRelationships/{{FIELD_ID}}/view
Is there a way to access this ID programmatically via the API in any way?
Upvotes: 0
Views: 889
Reputation: 19622
track when a custom field has been changed
You can query SetupAuditTrail. And when accessing SF via API - there's magic "If Modified Since" header (but read this too: https://salesforce.stackexchange.com/q/186494/799)
Is there a way to access this ID programmatically via the API
FieldDefinition is pretty good, I've made few answers about it here.
SELECT DurableId, EntityDefinition.QualifiedApiName, QualifiedApiName, DataType
FROM FieldDefinition
WHERE EntityDefinition.QualifiedApiName IN ('Account', 'Contact', 'myNamespace__myCustomObject__c')
works in normal queries (incl apex) and Tooling API.
Upvotes: 1