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
Sarath C RSarath C R 

Custom button to display a picklist

I have to use a custom button to update a picklist. The field is 'Industry' in the 'Lead' tab. I have created the button and entered the java script below
{!REQUIRESCRIPT ("/soap/ajax/24.0/connection.js")}

var records = {!GETRECORDIDS($ObjectType.Lead)};
var newRecords = [];
if (records[0] == null) {
alert("Please select at least one lead")
}
else {
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Lead");
c.id = records[n];
c.Industry =new Industry;
newRecords.push(c);
}
result = sforce.connection.update(newRecords);
window.location.reload();
}

but its showing the error like ' Industry is not defined '.

Can anyone help?
Cory CowgillCory Cowgill
This line is invalid:

c.Industry = new Industry;

What value are you trying to pu into c.Industry?

c.Industry is a Text field and requires a text value.

Doing '= new Industry' is not valid as Industry is not defined anywhere in your code, hence the error.

You could try something like c.Industry = "Technology" which would be valid because "Technology" is a literal value but would be static and not dynamic.

 
BalajiRanganathanBalajiRanganathan
c.Industry =new Industry;

the above line has a problem. Industry is the Picklist type on Lead. so it can have a string value
c.Industry = ""; or c.Industry = "Industry";