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
Pramitha Ayyappan NairPramitha Ayyappan Nair 

Custom Button JScript to set checkbox true

I have an OnClick JScript as below for a Custom Button, where I need to make the checkbox Escalated_Call__c to true. 

What is wrong with the below code- No error, but do not make checkbox true.

{!REQUIRESCRIPT("/soap/ajax/41.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}

var objCase = new sforce.SObject('Case');

objCase.Escalation_Reason_Details__c ='{!JSENCODE(Case.Escalation_Reason_Details__c)}';

if(objCase.Escalation_Reason_Details__c == '')
{
alert ('Please fill Escalation_Reason_Details__c');
}
else
{

objCase.Escalated_Call__c=true;

}
var result = sforce.connection.update([objCase]);
location.reload(true);
Best Answer chosen by Pramitha Ayyappan Nair
Dev-FoxDev-Fox
Hi Pramitha,
You didn't specify ID in update call.
objCase.Id='{!Case.Id}';
This will solve the issue.
Please mark as best if it works.
Thanks.

All Answers

Dev-FoxDev-Fox
Hi Pramitha,
You didn't specify ID in update call.
objCase.Id='{!Case.Id}';
This will solve the issue.
Please mark as best if it works.
Thanks.
This was selected as the best answer
Pramitha Ayyappan NairPramitha Ayyappan Nair
Missed it ... and Thank you :)
Pramitha Ayyappan NairPramitha Ayyappan Nair
Hi @Dev-Fox,

Do you know-how do we check if the Multipicklist value field is blank or not in this?
To replace the below Escalation_Reason_Details__c with a multi picklist value?

objCase.Escalation_Reason_Details__c ='{!JSENCODE(Case.Escalation_Reason_Details__c)}';

if(objCase.Escalation_Reason_Details__c == '')
{
alert ('Please fill Escalation_Reason_Details__c');
}

Thanks in Advance.