Jennifer Lee and Manish Thaduri in a new episode of "How I Solved It."

How I Solved It: Find Newly Created Fields in Salesforce

By

Welcome to another “How I Solved It.” In this series, we do a deep dive into a specific business problem and share how one #AwesomeAdmin chose to solve it. Once you learn how they solved their specific problem, you’ll be inspired to try their solution yourself! Watch how Manish Thaduri was able to find newly created fields without having to manually go through each individual field in an object to find its created date. Read more details in the post below.


Key business problem

For a Salesforce Admin, developer, or deployment manager, finding the list of fields created on a specific day is a tedious manual job. The user needs to open each individual field in the Object Manager in Setup and check the CreatedDate value. Good luck if you have to repeat that process for all the fields in the object manually and find the CreatedDate! We need a better, easier way to get that list of fields created on a specific day.

Background

Our client follows a 2-week sprint for their Salesforce development process. Every week, the admins or developers working on the project create and modify a number of fields in the sandbox. At the end of 2 weeks, our delivery lead (aka deployment manager) consolidates all the fields created in the prior 2 weeks and deploys them to production. There’s no easy way for the deployment manager to find all of these fields to add to the outbound change set to prepare for the deployment.

The manual way is to open the field from Object Manager > Fields & Relationships and then check the Created By field value of a field. There, the deployment manager would see the Created Date of the field. They have to repeat this manual process for all the fields in the object to find the Created Date.

A field showing its Created By date.

How I solved it

I opened the Developer Console from the dropdown on the top gear icon.

Accessing the Developer Console from the gear icon.

Then, I clicked the Query Editor tab and checked the Use Tooling API checkbox at the bottom.

The Query Editor tab selected and the Use Tooling API checkbox on the Developer Console.

I wrote a simple query to find the fields Created Today.

SELECT DeveloperName, TableEnumOrId FROM CustomField 
WHERE CreatedDate = TODAY
  • DeveloperName is the field name.
  • TableEnumOrId is the ObjectName/ObjectId.
  • I used a filter: CreatedDate = TODAY

The query found two fields—Approval_Date and Author. These are the fields created today in our Salesforce org in all the objects. It’s that simple!

The two records found with the query.

The column “TableEnumOrId” shows the object these fields are from.

  • For standard objects, the TableEnumOrId gives the name of the object directly like Account, Contact, Opportunity, etc. Here in our example, it shows Approval_Date is from the Account object.
  • For custom objects, it gives the Object ID. Author is from a custom object with the ID shown in the screenshot above. (You can easily open the object using the object ID by adding the ID in the object URL.)

For my scenario, I varied the WHERE condition and used CreatedDate is this_week or last_week. This would give me all the fields created in the last 2 weeks.

SELECT DeveloperName, TableEnumOrId FROM CustomField
WHERE CreatedDate = LAST_WEEK or CreatedDate = THIS_WEEK

I also tried LAST_QUARTER in the WHERE condition to expand my date range further and find all fields created in the last quarter in my org. There you go!

Query using the created date as last quarter.

Business results

Now, it’s super easy for my deployment manager and even admins and developers to get the list of fields created or modified during a certain time period without having to manually keep track of them.

Do try this at home

This example was real and it’s very simple. But the principle behind it could be applied in all sorts of ways just by varying the WHERE conditions. You can also filter fields based on the specific object name or even the LastModifiedDate of the field.

Let us know what you thought of this solution and tell us how you want to use it with #AwesomeAdmins #HowISolvedThis.

Resources

Want to see more good stuff? Subscribe to our channel!

SUBSCRIBE TODAY
Jennifer Lee and Simon Walsh in a new episode of "How I Solved It."

How I Solved It: Digitize Paper Forms Using Flow

Welcome to another post in the “How I Solved It” series. In this series, we do a deep dive into a specific business problem and share how one #AwesomeAdmin chose to solve it. Once you learn how they solved their specific problem, you’ll be inspired to try their solution yourself! Watch how Simon Walsh uses […]

READ MORE
Jennifer Lee and Cassie Supilowski in a new "How I Solved It' episode.

How I Solved It: Monitor Unwanted Changes to Reports

Welcome to another post in the “How I Solved It” series. In this series, we do a deep dive into a specific business problem and share how one #AwesomeAdmin chose to solve it. Once you learn how they solved their specific problem, you’ll be inspired to try their solution yourself! Let’s take a look at […]

READ MORE

Have an Idea for a Story?

We are all about the community and sharing ideas.
Do you have an interesting idea or useful tip that you want to share?

SHARE YOUR IDEA