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
Emilee Crocker 3Emilee Crocker 3 

How to get a button to change a custom field drop down?

I'm trying to get my custom button to change Lead Status to Converted in this script. Any help would be great!

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

sforce.connection.sessionId = "{!$Api.Session_ID}";

var E = new sforce.SObject("Lead");
E.id = '{!Lead.Id}';

// Replace below with your field.
E.To_Be_Set_Up__c=true;


// save the change
sforce.connection.update([E]);

//refresh the page
window.location.reload();
Raj VakatiRaj Vakati
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")}
try {
var c = new sforce.SObject("Lead"); 
c.id = "{!Lead.Id}"; 
c.Status = 'Converted '; 
result = sforce.connection.update([c]); 
}catch(e){
}
window.location.reload();

Use this code .
 
Emilee Crocker 3Emilee Crocker 3
I need the button to also mark to be set up as true so I added the script to what I already had but it is coming with the error c is undefinded.

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

sforce.connection.sessionId = "{!$Api.Session_ID}";

var E = new sforce.SObject("Lead");
E.id = '{!Lead.Id}';

// Replace below with your field.
E.To_Be_Set_Up__c=true;
c.Status = 'Converted';


// save the change
sforce.connection.update([E]);

//refresh the page
window.location.reload();