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.

| improve this question | | | | |
  • how can members help you without seeing your code? – Santanu Boral Jul 26 '18 at 10:11
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();
}
| improve this answer | | | | |
  • 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 Jul 26 '18 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 }

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.