You need to sign in to do that
Don't have an account?
AAI
button with 3 conditions
Hi ,
I would need a button with 3 conditions. However, the phone condition doesn´t work. Any idea?. Thanks in advance
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")}
var status = "{!Lead.Status}";
var Cartera__c = "{!Lead.Cartera__c}";
var Phone = "{!Lead.Phone}";
if (status == "Open" || status == "Assigned"){
if(Cartera__c!= null && Cartera__c!=""){
if(Phone != null && Phone !=""){
var lead = new sforce.SObject('Lead');
lead.id = "{!Lead.Id}";
lead.Status = "Pending conversion";
result = sforce.connection.update([lead]);
location.reload(true);
}
}else{
alert('Cartera Cannot be null');
}
}else{
alert("Invalid status. You can only submit to conversion the Lead if the status is Open or Assigned");
}
I would need a button with 3 conditions. However, the phone condition doesn´t work. Any idea?. Thanks in advance
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")}
var status = "{!Lead.Status}";
var Cartera__c = "{!Lead.Cartera__c}";
var Phone = "{!Lead.Phone}";
if (status == "Open" || status == "Assigned"){
if(Cartera__c!= null && Cartera__c!=""){
if(Phone != null && Phone !=""){
var lead = new sforce.SObject('Lead');
lead.id = "{!Lead.Id}";
lead.Status = "Pending conversion";
result = sforce.connection.update([lead]);
location.reload(true);
}
}else{
alert('Cartera Cannot be null');
}
}else{
alert("Invalid status. You can only submit to conversion the Lead if the status is Open or Assigned");
}
I just replaced "{!Lead.Cartera__c}"; with "{!Lead.Email}"; because I dont have the custom field in my Lead object.
You don't have a else condition for the IF you have on Phone, is that what you have trouble with?
Here is the code that worked for me, if this helps you.
It updated the data when I have Phone and email fields filled and Status = "Open - Not Contacted"