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
VS0184VS0184 

Trigger on Lookup Filed

Need some help on creating a trigger for the Leads object I don't think process builder or a workflow rule will help with this.

If Lead Owner Field has an owner , populate that same name in the Primary Sales Rep field.

Lead Owner Field(OwnerLookup) (User,Queue)
Primary Sales Rep field Primary_Sales_Rep__c Lookup (Primary Sales Rep)


Thanks in advance!!


 
Ashish DevAshish Dev
I think you can achieve this with process builder if you want to update Primary Sales Rep's field which is lookup.
Process builder configuration:
Object - Lead
Condition - Whenever owner is changed,something like -  [Lead].OwnerId  <>   PRIORVALUE([Lead].OwnerId ) 
Imidate action- 1) Action type - update records
2) Record Type - [Lead].Primary Sales Rep
3) Criteria for Updating Records* - No criteria
4) Under "Set new field values for the records you update" select field which needs to be updated of "Primary Sales Rep" object.
5) Type - Select formula
6) Value - [Lead].OwnerId