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 

Custom Button and checkbox fields

I am trying to create a custom button on a lead and opportunity that when clicked it will check a checkbox field.  I have tried a formula : (Lead.Lead_Counts_Against_User__c=True) and I get an error message Invalid Left-hand bside in Assignment. I have also tried code and get the same error message. Please help.  
Best Answer chosen by Dorel4
KaranrajKaranraj
If you want to update the field in the standard pagelayout from the custom button, try this javascript code in you cusotm button. Below code will set the field as true when you click that button. Make sure that you have choosen execute javascript in the behaviour of the custom butotn
 
{!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_counts_Against_User__c = True;
sforce.connection.update([leadrcd]);

 

All Answers

KaranrajKaranraj
If you want to update the field in the standard pagelayout from the custom button, try this javascript code in you cusotm button. Below code will set the field as true when you click that button. Make sure that you have choosen execute javascript in the behaviour of the custom butotn
 
{!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_counts_Against_User__c = True;
sforce.connection.update([leadrcd]);

 
This was selected as the best answer
Dorel4Dorel4
Karanraj,

Thank you for your help.  Now I get an error message 'True is not defined',  I tried defining True  by adding True=1 but I still get the True is not Define Error Message.  How do I define True?

Thank you,
Dorel