You need to sign in to do that
Don't have an account?

how to define a picklist value
I am trying to have my lead status (which is a pick list) select converted as well as marking to be set up as true (which is working currently) but i keep getting an error saying converted is undefined. My code is the following:
{!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;
// Replace below with your field.
{!Lead.Status}=converted
// save the change
sforce.connection.update([E]);
//refresh the page
window.location.reload();
{!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;
// Replace below with your field.
{!Lead.Status}=converted
// save the change
sforce.connection.update([E]);
//refresh the page
window.location.reload();
All Answers
In the above code snippet, you don't any variable with the name 'converted' but even though you are assinginng it to {!Lead.Status} which is the reason why you are gettting "converted is undefined".
Seems you want to assign 'converted' string to {!Lead.Status}. in that case, you need to update statement with below snippet: Hope this will resolve your issue. Kindly let me know in case any query.
Thanks,
Aman