2

I'm trying to do a large scale field cleanup within my org, and I'm looking to get a list of the custom fields by object (in this case the Account sobject), some basic details for those fields, and most importantly the created date of those fields. I cannot figure out how to get the created date though - which seems very odd.

Within the developer console, I'm using the Query Editor tab, and I'm entering in the following query:

SELECT QualifiedApiName, LastModifiedDate, DeveloperName, (Select DataType From Particles)
FROM FieldDefinition
WHERE EntityDefinition.QualifiedApiName ='Account'

I should note that I have the "Use Tooling API" checkbox enabled. If I enter in the CreatedDate attribute I get the following error back:

ERROR at Row:1:Column:44 No such column 'CreatedDate' on entity 'FieldDefinition'.

Can someone please point me in the right direction here? Seems very odd that I can't pull in the CreatedDate of a custom field, so I believe I'm doing something wrong.

  • Your query does not include the CreatedDate field... – Adrian Larson May 2 '18 at 14:58
  • 1
    @AdrianLarson i did a describe call on FieldDefinition. there is no field named as CreatedDate – Pranay Jaiswal May 2 '18 at 15:00
  • 1
    The CustomField Metadata API entity doesn't have a CreatedDate field either. – David Reed May 2 '18 at 15:03
  • There is only 'LastModifiedDate' not CreatedDate .. – Ayub May 2 '18 at 15:08
10

The FieldDefinition table doesn't have a CreatedDate field, but CustomField does (but it's not in the documentation). It seems to me that you'll need to perform two queries and then match up the records by DeveloperName:

SELECT NameSpacePrefix, DeveloperName, TableEnumOrId, CreatedDate, LastModifiedDate FROM CustomField WHERE TableEnumOrId = 'Account'

Plus your original query. Note that DeveloperName won't include the __c, so you'll need to check the results from FieldDefinition to determine if it should be a custom field or not.

| improve this answer | |
  • To add its available only via Toolin API, and The field Namespace is actually "NamespacePrefix" . – Pranay Jaiswal May 2 '18 at 15:17
  • 1
    @PranayJaiswal Yeah, I thought that looked weird. – sfdcfox May 2 '18 at 15:43
  • @sfdcfox amazing - this gave me exactly what I needed. Thanks! – Tom Kline May 2 '18 at 16:17
  • For Custom object, we can take the ID of object from the URL. Ex : SELECT NameSpacePrefix,DeveloperName, TableEnumOrId, CreatedDate, LastModifiedDate FROM CustomField WHERE TableEnumOrId = 'XXXXXXXXXXXXXXX' order by createddate desc In where condition just mention you object 15 digit ID that you can copy from the object field URL – KSL Jul 20 '18 at 13:28
  • Thanks, @sfdcfox helped a lot!! – Abhijith E Feb 25 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.