function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Formula for field update

Hi all,

i'm trying to create a workflow or formula field for implementing the following logic:
in my org we define the role in the following way - "Role Description - Location", i.e. "Education Counselor- Boston"

i've created a custom text field inside the lead object which called "location__c"
i'm trying to cut only the location part from the owner role and paste it into this location field. i want to do it every time a lead is created or edited.

for example: for a lead with an owner role of "Education Counselor- Boston" the location field should be "Boston".

Any help with that will be greatly appreciated.

Try this:
RIGHT($UserRole.Name, LEN($UserRole.Name) - FIND($UserRole.Name, " - ") - 6)
Thanks for your quick reply. the formula that you've suggested will bring the current's user location. i need the lead owner location.
any ideas?

Ah.  You can't use the owner as a relationship in a formula because it's polymorphic, i.e. it can be either a queue or a user (and a queue would have no role).

This, then, is a job for an Apex trigger, probably one on before insert and before update that detects if the owner is a user, and if it is, finds that user's role, parses it out and puts it in your custom field.

i'll use a trigger - thank you!