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
AAIAAI 

Button Doesn´t work if I add the phone condition

Hi all,

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");
}
Lokesh KumarLokesh Kumar
HI AAI,

can you please check the record field value before doing an update via button click however it's working for me with the same code only i removed your custom field criteria but as you are facing an issue with phone filed i have verified and working fine.

let me know if you have any question
Thanks!
AAIAAI
Sorry, I don´t understand very well your answer. I need that the code verifies the 3 conditions and if not, the alerts must be displayed.

I would appreciate any idea.

Thanks