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
Iman NazarianIman Nazarian 

OnClick JavaScript Button help needed

Hi everyone,

I am trying to create a button for the case object that checks a custom checkbox when you click on it (not on the edit page but on the details page).

I have tried using this piece of code but I get an error message saying: "Unexpected token ILLEGAL"

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

var myCase = new sforce.SObject("Case.Id);
myCase.Id = "{!Case.Id}";
myCase.Initial_Interaction_Completed__c = "true";
var result = sforce.connection.update([myCase]);
window.location.reload();
 
Best Answer chosen by Iman Nazarian
Pramodh KumarPramodh Kumar
Please try this code. you missed double quote " in the line and .id in the same line

var myCase = new sforce.SObject("Case.Id); 
 
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

var myCase = new sforce.SObject("Case");
myCase.Id = "{!Case.Id}";
myCase.Initial_Interaction_Completed__c = true;
var result = sforce.connection.update([myCase]);
window.location.reload();
Let me know if you still having any issue.

Thanks,
Pramodh