​How to get previous "Owner Name" of records on the page by using formula? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Josh sJosh s 

​How to get previous "Owner Name" of records on the page by using formula?

Hello,
I want to display last owner name of the records on the page by using formula. Is it possible ?
Suppose,  opportunity or account owner is changed than 
previous owner name should display in seprate field on the page? How we can use the formula to achieve this ? 

Thanks ..

Best Answer chosen by Josh s
Mayank SrivastavaMayank Srivastava
Jennifer, you unfortunately cannot use a PRIORVALUE in a formula field.

Rahul, here's how you can do it:

1. Create a Prior Owner custom text field to hold the previous owner.
2. Then create a Process like this:

User-added image

User-added image

User-added image

Formula:
PRIORVALUE([Account].Owner.FirstName ) + " " + PRIORVALUE([Account].Owner.LastName)

3. Activate the process and you are done!
 

All Answers

Deepak AnandDeepak Anand
Not exactly but yes, you could get close but I am not really sure if that's the recommended way though. This is how it works = 
  1. Create a Formula Field on the Object = 
    • Label: Owner Name
    • Type: Formula
    • Return Type: Text
    • Formula: 
      Owner.FirstName + " " + Owner.LastName
  2. Now, setup a Workflow Rule + Field Update like this = 
    • Evaluation Criteria: created and every time it's edited [2ND OPTION]
    • Rule Criteria: formula evaluates to true
    • Formula: 
      ISCHANGED(OwnerId)
    • Add a Field Update as the Immediate Action
    • Field to Update: Create a Text Field called "Old Owner"
    • Select a Use a Formula to Set the New Value
    • Formula:
      PRIORVALUE(Owner_Name__c)
    • Save & Activate
Alternatively another way: Getting Old Owner Name using Processes
Jennifer W. LeeJennifer W. Lee
Have you tried using this formula: priorvalue (field API name)?
Mayank SrivastavaMayank Srivastava
Jennifer, you unfortunately cannot use a PRIORVALUE in a formula field.

Rahul, here's how you can do it:

1. Create a Prior Owner custom text field to hold the previous owner.
2. Then create a Process like this:

User-added image

User-added image

User-added image

Formula:
PRIORVALUE([Account].Owner.FirstName ) + " " + PRIORVALUE([Account].Owner.LastName)

3. Activate the process and you are done!
 
This was selected as the best answer
Josh sJosh s
Hi  Guys,
Thanks for replying

Hi Mayank ,
I have created processbuilder on account/ opportunity object 

I was trying to perform the task but when i was changing the record " owner name " & trying to save the record, i am getting below error: I 
====== error msg =======.
Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30128000000PKLo.
=============

Thanks ...
Mayank SrivastavaMayank Srivastava
Rahul, can you post the screenshots for all parts of your Process here. Also, you must have received a detailed error message in Email for the above failure. Can you post it here too?

Also make sure that there are no validation rules or other workflow rules/processes interfering with the update. 
Josh sJosh s
Hi Mayank,
I checked , there is no validation/workflow rule is activated. But it is working when I tried to create it by workflow,
 Please find the below screenshot for PB :- 

1.
User-added image

2.
User-added image

3.
User-added image

4.
User-added image

PRIORVALUE ([Account].Account_name__c.Owner.FirstName) +" "+ PRIORVALUE ([Account].Account_name__c.Owner.LastName )


====================
Email :- >


Error : -

An error occurred at element isChangedDecision2_myRule_1_OwnerId (FlowDecision).
The flow failed to access the value for myVariable_old.test1__r.OwnerId because it hasn't been set or assigned.

This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.
Flow Details
Flow Name: Prior_Owner_opp
Type: Workflow
Version: 1
Status: Active
Flow Interview Details
Interview Label: Prior_Owner_opp-1_Opportunity
Current User: Rishi k (00528000000xpF2)
Start time: 12/22/2015 8:32 AM
Duration: 0 seconds
How the Interview Started
Rahul S (00528000000xpF2) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 00628000004V1wQAAS
myVariable_current = 00628000004V1wQAAS
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "12/22/2015 8:32 AM"
Mayank SrivastavaMayank Srivastava
Rahul,
What is Account_Name__c in your formula? Aren't you using the standard Owner field on Account object to track Account Owners? The formula should simply be:
PRIORVALUE([Account].Owner.FirstName ) + " " + PRIORVALUE([Account].Owner.LastName)
There is no need for Account_Name__c.
 
Josh sJosh s
Hi Deepak,
Yes, I tried by using workflow, it is working. But when writing formula  “owner name” –  -

Field update : 
PRIORVALUE(Owner_Name__c) 

-----
error showing:  Field doesn’t exist,
------
so do we need to create a  ‘text’ custom field.  
I used “owner Id”  to  return the previous owner id

Field update : 
PRIORVALUE(Owner_ID__c)  

But what if I want to convert the owner id for owner name.
So, how we can convert the owner id into owner name. & which field  will be suitable for bringing owner name using
PRIORVALUE in formula  in field update
Josh sJosh s
Hi Mayank,

Applogies, bymistake i had choosen wrong field value .

Now, I have created a new PB with correct value - but still same error is coming. below is the screenshot

User-added image


when i was changing the record " owner name " & trying to save the record, i am getting below error: 

Workflow Action Failed to Trigger Flow

The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30128000000PKRr.


=========


An error occurred at element isChangedDecision2_myRule_1_OwnerId (FlowDecision).
The flow failed to access the value for myVariable_old.Owner.Account.Account_name__r.Owner.Account.OwnerId because it hasn't been set or assigned.


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange.


Flow Details
Flow Name: Process_Builder_for_account_return_the_previous_owner_name
Type: Workflow
Version: 1
Status: Active


Flow Interview Details
Interview Label: Process_Builder_for_account_return_the_previous_owner_name-1_Account
Current User: Rahul S (00528000000xpF2)
Start time: 12/23/2015 8:37 AM
Duration: 0 seconds


How the Interview Started
Rahul S (00528000000xpF2) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = 0012800000DZNhWAAX
myVariable_current = 0012800000DZNhWAAX


ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "12/23/2015 8:37 AM"


 
Mayank SrivastavaMayank Srivastava
Why is your flow still referencing the:
myVariable_old.Owner.Account.Account_name__r.Owner.Account.OwnerId variable?

Are you using Account_name__r anywhere in your Process? If yes, please remove that. Can you post the Field being used in your Process criteria?
Josh sJosh s
Hi Mayank,
I am sorry. yes u r right there was a mistake in criteria , now it is working properly..
Thanks bhaiya for your cooperation ,help & guidance.

just for curiosity  sake , i tried by using workflow it is working.fine.
can you please see my above email which i have addressed to deepak & suggest.








 
Josh sJosh s
Happy holidays to everyone & merry christmas .. :)