Monday, 25 April 2016

How do you know who created a Custom Object Field?

How do you know who created a Custom Object Field?

Every now and again a seemingly simple question turns out to be much trickier than you originally thought.

Someone recently asked me:
"How can I find out when and who created a particular field on a custom object?"
It turns out the answer was slightly more complicated that I first thought:



A Report?

Unfortunately there is no report that shows you this setup information.

I came across this Idea on the IdeaExchange suggesting to Salesforce that they create this in future.


Check the Custom Object's setting?

My first thought for this question was to have a look at the Custom Object itself in Salesforce. 

When navigating to the Custom Object you can see a list of all Standard and Custom Fields.

Custom Object shows Last Modified Date
After a closer look though I realised that you can only see "Last Modified" this way, not the Created Date. To see the created date you actually need to click on the field name to see a view like this one:

You can check field creation date individually via the Object screen
Many thanks for Elizabeth Davidson for pointing this step above out.

So, you can check fields individually on the Object screen, but what if you report on multiple fields at a time?

Query via SOQL or the Metadata API?

After seeing that the Custom Object page didn't give us all of the information we needed at a glance, I wondered next if we could query this information via the Developer Console.

After a lot of experimentation I just couldn't find a query to do this. You can easily find out when a record was created and who created it but not the actual field itself.

I read a great post from Andy In The Cloud regarding the possibilities of the Metadata API to get at this information but by this stage I decided to simplify the problem and go back to the user with a straightforward solution.


Ask the Community?

The Salesforce Success Community is a great resource if you ever need additional support.

I posted my question on the community and received a couple of really useful replies, including the solution that I eventually gave back to the user. If you want to see the whole thread of the discussion you can visit the question via the link below.

Setup Audit Trail

So, having tried to do this the easy way (reports/looking at Custom Object/checking fields individually) and the hard way (SOQL and/or Metadata) my next port of call was the trusty Setup Audit Trail

Field creation events show in Audit Trail
Setup Audit Trail shows field creation events clearly, however it also shows you all other system changes by all users so it needs filtering to find specific information.

As a first step, I exported the Setup Audit Trail to a spreadsheet.

Once exported to a Spreadsheet you can easily filter the data
Then, once I had the data in a spreadsheet I added filters for 'created custom fields' and applied that to column C labelled 'Action'.

A combination of filters and object name saved the day
This then showed me a list of created fields across all objects. If I had needed to, I could have created a second filter to only show created fields on a specific object.

Conclusion

In response to the question:
"How can I find out when and who created a particular field on a custom object?"
  • I looked for a Salesforce report,
  • I looked at the on screen information for the Custom Object and found that you can check individual fields from there, 
  • I then experimented to see whether the Query Editor would allow me to query for this information
  • and lastly, I exported the data from the Setup Audit Trail.

If you are only interested in a few fields clicking on the Object and then Field Name is my recommended way to go. If you need to query multiple fields then I found that Setup Audit Trail gave me all of the information the user needed in a single report.

It was interesting to note that:
  1. You can only see the past 6 months of data - fields created longer ago than that would not have shown (you would have to stick with checking each field individually via the Object)
  2. You have to download the data first before you can do anything with it
  3. You have to manually separate out the information you don't need 
  4. You then have to save the manipulated file to send back to the user
I'd be really interested in seeing whether Salesforce add more functionality to the Audit Trail in future or allow for administrative type reports that would easily allow an admin to query this data.

Icon from Iconfinder, artist Oliver Scholtz