Skip to main content
Hi,

I have created a custom button in java on the Lead List view and cannot get it to work properly.

As its a button on the list view it first checks you have selected a record, otherwise shows an error and then once records are selected it needs to check that a picklist field is 'MQL' and if so changes the value of a few fields.  If the picklist is anything else other than MQL it displays and error.

I am nearly there but the error on th epicklist shows regardless of the picklist value....

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

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

var records = {!GETRECORDIDS($ObjectType.Lead)};

var newRecords = [];

if (records[0] == null) {

alert("Please select at least one row");

} else {

if('{!Lead.Lead_Lifecycle_Stage__c}' != "Marketing Qualified Lead (MQL)") {

alert("You cannot Take Ownership of this lead until it has reached the Marketing Qualified Lead (MQL) stage.\n\n If you would like this lead fast tracked to MQL, please contact Marketing.");

} else {

for (var n=0; n<records.length; n++) {

var l = new sforce.SObject("Lead");l.id = records[n];

l.OwnerId ="{!$User.Id}";

l.Status = "Open";

l.Lead_Lifecycle_Stage__c = "Sales Accepted Lead (SAL)";

newRecords.push(l);

}

result = sforce.connection.update(newRecords);

parent.window.location.reload();

}

}
2 answers
  1. Nov 11, 2016, 8:36 AM
    Hi,

    Try using

     

    if('{!Lead.Lead_Lifecycle_Stage__c}' != "Marketing Qualified Lead (MQL)") {

    IF(!(ISPICKVAL(Lead_Lifecycle_Stage__c,'Marketing Qualified Lead (MQL)')))

    Hope this helps you!

    If this helps you please mark it as solved.

    Thanks and Regards

    Sandhya

     
0/9000