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
jamesclark clarkjamesclark clark 

How to change the owner of the record

Hi all,
I want to change the owner of the record when a field value is equal to the value of the another field in another object.
example:In lead object, custom field value is equal to the value of my custom object field then i want to change the owner of the lead as my custom object assigned user.
Can anyone help me over here.

Regards,
james
Nirdesh_BhattNirdesh_Bhatt
Hi Jamesclark,
Unfortunately, you can't auto-populate a Lookup field via a Formula or a Workflow Rule with a Field Update.  But you can at least create a Validation Formula that will throw an error if the 2 fields are not the same.
 
OwnerId <> Custom_Lookup_Field
Jyosi jyosiJyosi jyosi
Hello James,

You can write trigger, like before update
I think its has lookup relation.
Query the lead field which you need to compare
when the field gets mapped to your value in lead we  need to get the custom object username and update the lead.
please let me know if you need code.

Thanks

Regards,
Jyo
Rakesh51Rakesh51
Hi James,

What is the relation between lead and custom object? You can either use Apex trigger or Flow with Process Builder (Declarative).

R
Bhargav krishna 1Bhargav krishna 1
Hi Jyosi,
Can you please post the code it will to know how to write the code for these kind of scenarios.

Thanks in advance.
Regards,
Bhargav.