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
Nick.E.DelisNick.E.Delis 

Button for Changing a Lead Automatically to the new Lead owner when Pressed

Does anyone have experience with  the code for a button to automatically change the lead owner to that person? I think it is pretty simple... but I don't want them to go through any additional steps just press the button... Thanks for the help!

info.shailinfo.shail

Hi Nick, you can try this on button click, ll work -

 

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/19.0/apex.js")}

var shp= new sforce.SObject("Lead");
shp.Id = "{!Lead.Id}";
shp.OwnerId = "{!$User.Id}";
sforce.connection.update([shp]);
window.location.reload();