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
SabrentSabrent 

Workflow to capture old value

On the Accounts object i have a custom lookup field called 'Account Manager' of type user.
I also have another custom field 'Previous Manager' of type Text. What I am trying to do is, when the Account Manager is changed,copy the old value of 'Account Manager' to 'Previous Manager. To achieve this, I have created a workflow with the following properties,

Rule Criteria: ISCHANGED(Account_Manager__C)

Field to Update: Previous Manager    
Formula Value: PRIORVALUE(Account_Manager__c)

Of course this gives me the record id of the user, to get the Manger's Name (FirstName Last Name) I did,

 

PRIORVALUE(   Account_Manager__r.FirstName & ' '&  Account_Manager__r.LastName ),

 

However it gives me the error 'Incorrect argument type for function 'PRIORVALUE()'

How can I get the Manager's First Name and Last Name?

Thanks!!

Starz26Starz26

If you are looking for a pure declarative solution:

 

1. Create a formula field on the object that is set to the value of the first name and last name of the relationship

 

      i.e -> FieldName = ManagerName - text value = Account_Manager__r.FirstName & ' '&  Account_Manager__r.LastName

 

2. Set the workflow rule to use the prior value of the formula field you created and put that value in the field you want..

 

     Priorvalue (ManagerName__c)

SabrentSabrent

Thanks for your response.

 

If I have to do it programatically, is trigger the way to go?

 

RajaramRajaram

If you are looking for the information in a trigger, you can use the Trigger.old to get the prior value.

SabrentSabrent

Thanks a lot. Just remembered about Trigger.old

ForceNoobForceNoob

It is easier if the Previous Manager Field is a lookup to the User object. This way, if you update it with the record ID, it will show the name.

SabrentSabrent

Thanks, yes the Previous Manager field is a lookup to User.

{tushar-sharma}{tushar-sharma}
After Spring 21 release we can now get Old values in Salesforce Flow. Check my post in which I have covered step by step how we can do this.

https://newstechnologystuff.com/2020/12/20/get-old-values-in-record-triggered-flow/