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
bridgerlandbridgerland 

Mapping Fields - Auto Populate

On the Leads tab, I created a field named "Salesperson".  I would like this field to auto populate the name in the Lead Owner field. I don't know how to map two fields on the Leads Tab.  Can anyone please help? 

 

 

Pradeep_NavatarPradeep_Navatar

You need to create a formula field to achive this. By using formula field, you will be able to retrieve ownerid in the salesperson field.

 

Hope this helps.

mR_nGmR_nG

You can create a trigger to do that.

 

here an example:

 

//The trigger declaration - this will fire before inserts abd updates to Leads

trigger LeadRegin on Lead (before insert, before update) {

 

  // iterate through each Lead record in the input batch

  for (Lead l : Trigger.New) {

   

    // Fetch from the DB the User record that is the owner

    User theOwner = [SELECT I, Region__c FROM User WHERE Id = :l.ownerId];

 

    // Set the REgion field of the Lead to the REgion field of the owner

    l.Region__c = theOwner.Region__c;

  }

}