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
TGHTGH 

Update Custom Field to Office of New User

Hi,

 

I'm trying to enable a workflow rule that will do the following: When a Case is created, or when the Case's Owner changes, I want to update a field labeled "Office" that identifies which global office has been assigned the case. This Office custom field is a picklist (and we all know how fun using formulas for picklists is).

 

So I created a workflow rule using the following formula and everything seemed like it turned out great:

CASE(  $User.Office__c   ,
"Americas", "Americas",

"France", "France",

etc. )

 

It seemed like it worked great. But then I discovered that it's not changing the Office field to display whatever the office of the user who has been assigned the case ... it's assigning it to the user who last edited the Case Owner field.

 

So if a user in France is assigned the case, and it should be handled by someone in America, so the user changes the ownership to an American user, the Office field is still going to read "France" because the user who changed it is in the French office.

 

Ow. Could anyone suggest a way to me to display in my custom field the Office of the user who has been assigned the case, not the user who last edited the Owner field?

 

Thanks!

Message Edited by TGH on 03-20-2009 10:52 AM
MarkSilberMarkSilber
I've got some bad news / good news for you.

Bad news: As you figured out, $User is the currently logged in user, not a user related to a Case. Because on Cases and Leads the Owner could be either a User or a Queue, you don't have access to related fields for the user when building a formula for a field update -- you only have access to OwnerID.

Good news (depending on how you look at it): You can accomplish what you are trying to do, but it will require a trigger on the Case object. Within the trigger you have access to the current and previous owner (when saving the record). The trigger could grab the value from the User record and update a field on the Case while it's being saved (before update). Writing triggers isn't a trivial task, but the trigger to do what you are asking would only be a few lines of functional code. In addition to writing the trigger, you would also have to have a test class and then use Eclipse to move the code from your sandbox to production since you can't create or modify triggers / classes directly in a production environment.
TGHTGH

Thanks. What we were actually looking for was which office was actually closing the case. So I've set up a workflow rule to update to the user's office when the user closes the case. Not the most elegant solution, but we seem happy with it.

 

Thanks for the suggestion!