0

I would like to create a Detail Page JS button with the below (under the Lead object if it matters)

If A=TRUE and the button is pressed, update checkbox B to TRUE. If A=FALSE and the button is pressed, show Alert "Not the Right Case"

Really straight forward yet am having issues implementing. Any help is much appreciated.

var newRecords = []; 
var c = new sforce.SObject("Lead"); 
c.id ="{!Lead.Id}"; 


if ({!Lead.RedCarpetSignup__c}= true) 
{ 
c.{!Lead.Email_Verified_and_Activated__c} = true;
}


newRecords.push(c); 
result = sforce.connection.update(newRecords); 
window.location.reload();

Thanks.

1
  • how can members help you without seeing your code? Commented Jul 26, 2018 at 10:11

2 Answers 2

0

Solution will be like this

{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")} 
var caseObj = new sforce.SObject("Case"); 
var CustomFieldValue = "{!Case.CustomField__c}"; 


if(CustomFieldValue==false) 
{ 
    alert("Not the Right Case"); 
}
else
{ 
    caseObj.CustomCheckbox__c = true;
    var result = sforce.connection.update([caseObj]);     
    location.reload();
}
1
  • I used the below yet the checkbox is not turning on: {!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")} var caseObj = new sforce.SObject("Lead"); var CustomFieldValue = "{!Lead.A}"; if(CustomFieldValue==false) { alert("Not the Right Case"); } else { caseObj.B = true; var result = sforce.connection.update([caseObj]); location.reload(); } Any idea?
    – AmitZ
    Commented Jul 26, 2018 at 11:55
0

you have to use the following strategy

{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")} if({! !your_Object_api_name__c.your_checkbox_api_name__c}){ alert('your custom message'); } else{ //update checkbox B to TRUE }

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .