5

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.

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

1 Answer 1

16

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.

5
  • To add its available only via Toolin API, and The field Namespace is actually "NamespacePrefix" . Commented May 2, 2018 at 15:17
  • 1
    @PranayJaiswal Yeah, I thought that looked weird.
    – sfdcfox
    Commented May 2, 2018 at 15:43
  • 1
    @sfdcfox amazing - this gave me exactly what I needed. Thanks!
    – Tom Kline
    Commented May 2, 2018 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
    Commented Jul 20, 2018 at 13:28
  • Thanks, @sfdcfox helped a lot!!
    – Abhijith E
    Commented Feb 25, 2020 at 20:10

You must log in to answer this question.

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