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
Nicholas PatellaNicholas Patella 

Custom Button to Check Box on Multiple Contact Records

I am trying to create a custom button that will allow me to select one or more Contacts from the "Contacts" related list on an Account page and then execute JavaScript which will update a specific field (in this case, simply setting a checkbox value to "true") on each of the selected Contacts. I would then use the updating of this checkbox value to trigger a workflow that would send out an email alert to those Contacts.

Here is how I've configured the custom button:
User-added image
I've done a lot of searching around and found other posts about people trying to do a similar thing but for some reason the script I'm using just won't update that Contact field (doesn't throw an error, just refreshes the page without updating). Any ideas what I might be doing wrong here?
Best Answer chosen by Nicholas Patella
SATHISH REDDY.SATHISH REDDY.
Also looks like your script doesn't handle multiple contact records. This should help you to achieve multiple Contact updates - https://success.salesforce.com/answers?id=9063A000000l9gSQAQ

All Answers

Nicholas PatellaNicholas Patella
Screenshot didn't come through very clear, here is my script:

{!requireScript("/soap/ajax/45.0/connection.js")} 
var c = new sforce.SObject("Contact"); 
c.id = '{!Contact.Id}'; 
c.Send_Settings_Survey__c = true; 
sforce.connection.update([c]); 
window.location.reload();
SATHISH REDDY.SATHISH REDDY.
Replace window.location with document.location
{!requireScript("/soap/ajax/45.0/connection.js")} 
var c = new sforce.SObject("Contact"); 
c.id = '{!Contact.Id}'; 
c.Send_Settings_Survey__c = true; 
sforce.connection.update([c]);
document.location.reload(true);
Tested & works fine. Please mark it as the best answer so that others can benefit. Thanks!
SATHISH REDDY.SATHISH REDDY.
Also looks like your script doesn't handle multiple contact records. This should help you to achieve multiple Contact updates - https://success.salesforce.com/answers?id=9063A000000l9gSQAQ
This was selected as the best answer
Nicholas PatellaNicholas Patella
Thanks Sathish. I used the script exactly as you have it above but the field is still not updating. Is there something else outside of this script that would be preventing this from working?
Nicholas PatellaNicholas Patella
Tried the script in the link you shared and it worked! As you indicated, it looks like the issue was that my script was designed for single record updates and not multiple record updates. Thanks so much!