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 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();
Best Answer chosen by Emilee Crocker 3
Waqar Hussain SFWaqar Hussain SF
try below code snippet.
 
E.Status = 'converted';

 

All Answers

Aman MalikAman Malik
Hi Emilee,
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:
{!Lead.Status}='converted';
Hope this will resolve your issue. Kindly let me know in case any query.

Thanks,
Aman
 
Waqar Hussain SFWaqar Hussain SF
try below code snippet.
 
E.Status = 'converted';

 
This was selected as the best answer
Emilee Crocker 3Emilee Crocker 3
This way worked! Thank you!