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
Dorel4Dorel4 

Unexpected Number Error message on a custom button

Hello,  I am trying to create a custom button on a lead and opportunity page.  When the button is clicked, the checkbox on the field Lead Counts Against User will be checked.  I get an error message Unexpected Number when I try to click the button.  Here is my code;

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
var leadrcd = new sforce.SObject("Lead"); 
leadrcd.id = "{!Lead.Id}"; 
leadrcd.{!Lead.Lead_Counts_Against_User__c}=="TRUE"; 
sforce.connection.update([leadrcd]);

Please let me know what I am doing wrong.  I have tried it with one = also.

Thank you
Best Answer chosen by Dorel4
KaranrajKaranraj
Try with the belwo code Dorel.
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
var leadrcd = new sforce.SObject("Lead"); 
leadrcd.id = "{!Lead.Id}"; 
leadrcd.Lead.Lead_Counts_Against_User__c = "TRUE"; 
sforce.connection.update([leadrcd]);

All Answers

KaranrajKaranraj
Try with the belwo code Dorel.
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
var leadrcd = new sforce.SObject("Lead"); 
leadrcd.id = "{!Lead.Id}"; 
leadrcd.Lead.Lead_Counts_Against_User__c = "TRUE"; 
sforce.connection.update([leadrcd]);
This was selected as the best answer
Dorel4Dorel4
Thank you it worked.
KaranrajKaranraj
If this solved your problem can you select the correct answer as best answer? it will be helpful for some one who faces similar kind of issue in future.