Have you ever created a formula field on a record and attempted to reference information from that record’s owner, such as a custom field that you have on the User object? All you can pull into your formula is the Owner ID! It’s quite the rude awakening, isn’t it?

Formulas cannot transverse the standard owner lookup record, but they can with custom ones – just another of the charming quirks of Salesforce. For those of us who aren’t very fluent in Apex code, this can be pretty unfortunate!

However… there is an easier way to make those custom fields available, and all you need is one trigger. What’s more, it has already been written for you. This is one of the easiest customizations, I have ever done, and I’m no developer. Here’s how to do it:

1) In your sandbox, create a custom Lookup Relationship field on the Account object (I named my custom field “Owner Copy”). Relate it to the User object.

2) Also in your sandbox, create a new Trigger on the Account object. Use this code, substituting the name of your custom field for Owner Copy:

3) Use outbound and inbound change sets to deploy your custom field and your trigger to your production instance.

You’ve now made a field that is just a copy of the account owner, and created a trigger to map the owner’s name to that field. After mapping, a separate formula field can be used on your custom field to move up the user record and pull whatever information is needed (generally role name information or custom user object fields, but it can be used for anything including alerting delegated approvals or managers, etc).

So now when I go to create my formula field, I can access all of the fields that exist in the Account owner’s User record:

Note: You can also create this trigger for other objects. Just replace ‘Account’ with whatever object you prefer (Lead, Contact, Opportunity).

Lastly, I’m very lucky to have a friend who is generous with his advice and incredible knowledge of Salesforce – so I need to say thanks Gabe!! (a.k.a. John Gabriel Athitakis) This trigger saved me a lot of grief. I hope it can do the same for my readers.

Liked this post? Follow this blog to get more.