You need to sign in to do that
Don't have an account?
AAI
Custom button with multiple if conditions
Hello All,
I have create a custom button. I need that the code validation that: "Lead status" is open and custom field "country" is not null. Any idea??.
Here is my code:
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")}
status = "{!Lead.Status}";
Country__c = "{! Lead.Country}";
if (status == ('Open'),
if (Country__c != ('null'){
var lead = new sforce.SObject('Lead');
lead.id = "{!Lead.Id}";
lead.Status = "Pending conversion";
result = sforce.connection.update([lead]);
location.reload(true);
}
else{
alert("Invalid status. You can only submit to conversion the Lead if the status is ('Open");
}
I have create a custom button. I need that the code validation that: "Lead status" is open and custom field "country" is not null. Any idea??.
Here is my code:
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")}
status = "{!Lead.Status}";
Country__c = "{! Lead.Country}";
if (status == ('Open'),
if (Country__c != ('null'){
var lead = new sforce.SObject('Lead');
lead.id = "{!Lead.Id}";
lead.Status = "Pending conversion";
result = sforce.connection.update([lead]);
location.reload(true);
}
else{
alert("Invalid status. You can only submit to conversion the Lead if the status is ('Open");
}
Try blow code. The error was due to that you were using, instead of { after first IF condition.
Note: - Change the values of Status as per your requirement in both places in Condition Check and Updating to new values as I tried this in my dev org in Order to make this work.
It will do the trick.
Mark as best answer if this work :)
Thanks,
Amit Singh
All Answers
Thanks in advance
Amaya
Try blow code. The error was due to that you were using, instead of { after first IF condition.
Note: - Change the values of Status as per your requirement in both places in Condition Check and Updating to new values as I tried this in my dev org in Order to make this work.
It will do the trick.
Mark as best answer if this work :)
Thanks,
Amit Singh