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
Nils11Nils11 

How to change owner of lead as current owner in javascript ?

var LeadToUpdate = new sforce.SObject("Lead"); 
LeadToUpdate.Id = "{!Lead.Id}"; 
LeadToUpdate.OwnerId = '{!$User.Id}'; 
sforce.connection.update([LeadToUpdate]);

I am using this code but owner not changing
GauravGargGauravGarg
Hi Nils,

To get current user in Javascript use below code:
sforce.connection.getUserInfo();


Hope this helps!!!

Thanks,

Gaurav
Skype: gaurav62990