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
PriscillaO_PriscillaO_ 

custom list button to update checkbox field for multiple records

Hi,
I'm getting an error when trying to do this:
click a custom list button in a specific Accounts list view that will update the Key Account checkbox field for the selected records.

checkbox field to update: Key_Account__c
custom button behavior: execute javascript

CUSTOM BUTTON CODE:

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

if({!Account.Key_Account__c} == false) 

var c = new sforce.SObject("Account"); 
c.id = "{!Account.Id}"; 
c.Key_Account__c = true; 
result = sforce.connection.update([c]); 
if ( result[0].getBoolean( "success" ) ) 

window.location.reload(); 

else 

alert( result[0].errors.message); 


else 

alert("Already True"); 
}

Thank you in advance!!!
PriscillaO_PriscillaO_
The error message says: "Unexpected token == "
v varaprasadv varaprasad
Hi Priscillo,

Your code is working I have tested in my Org and am using chrome.
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")} 

if({!Account.DeleteOpp__c} == false) 
{ 
var c = new sforce.SObject("Account"); 
c.id = "{!Account.Id}"; 
c.DeleteOpp__c = true; 
result = sforce.connection.update([c]); 
if ( result[0].getBoolean( "success" ) ) 
{ 
window.location.reload(); 
} 
else 
{ 
alert( result[0].errors.message); 
} 
} 
else 
{ 
alert("Already True"); 
}

Please check once javascript is enabled or not for your browser.

Thanks
Varaprasad


 
v varaprasadv varaprasad
It will update only one record at a time.added to detail page of account  record.



 
PriscillaO_PriscillaO_
the code isn't working for me... this one you have is a button for deleting opportunities right? 
i need the button to update the Key_Account__c field for multiple records selected from a list view. Thanks!