• Martijn Hindriksen2
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I am trying to build two buttons that executes JavaScript.
The function of the first button is to remove multiple items below a related list.
The function of the second button is to update a field on multiple records below a related list.
The related list is a custom object that links Contacts with a Delivery custom object (many to many relationship)

The functionality of the first button, what I am trying to create, is to select multiple rows and press a button to delete the selected rows.
The code I am using is below
{!REQUIRESCRIPT('/soap/ajax/35.0/connection.js')}

var selectedDeelnemers = {!GETRECORDIDS(   $ObjectType.Deelnemer__c   )};
sforce.connection.deleteIds(selectedDeelnemers);
navigateToUrl (window.location.href);
However I get the following error: 
User-added image

The second button should update a checkmark field called "Aanwezig" on the selected records. However I get the same error for the second button with the following code:
 
{!REQUIRESCRIPT('/soap/ajax/35.0/connection.js')}

var selectedContactIds = {!GETRECORDIDS( $ObjectType.Deelnemer__c )};
var contactsForUpdate = [];

if (selectedContactIds[0] == null) {
    alert(“You must select at least one record”);
} else {
    for (var i = 0; i < selectedContactIds.length; i++) {
       var contact = new sforce.SObject(“Contact”);
       contact.Id = selectedContactIds[i];
       {!Deelnemer__c.Aanwezig__c} = true ;
       }
}

var saveResult = sforce.connection.update(contactsForUpdate);
location.reload(true);
What am I doing wrong here?
 
I am trying to build two buttons that executes JavaScript.
The function of the first button is to remove multiple items below a related list.
The function of the second button is to update a field on multiple records below a related list.
The related list is a custom object that links Contacts with a Delivery custom object (many to many relationship)

The functionality of the first button, what I am trying to create, is to select multiple rows and press a button to delete the selected rows.
The code I am using is below
{!REQUIRESCRIPT('/soap/ajax/35.0/connection.js')}

var selectedDeelnemers = {!GETRECORDIDS(   $ObjectType.Deelnemer__c   )};
sforce.connection.deleteIds(selectedDeelnemers);
navigateToUrl (window.location.href);
However I get the following error: 
User-added image

The second button should update a checkmark field called "Aanwezig" on the selected records. However I get the same error for the second button with the following code:
 
{!REQUIRESCRIPT('/soap/ajax/35.0/connection.js')}

var selectedContactIds = {!GETRECORDIDS( $ObjectType.Deelnemer__c )};
var contactsForUpdate = [];

if (selectedContactIds[0] == null) {
    alert(“You must select at least one record”);
} else {
    for (var i = 0; i < selectedContactIds.length; i++) {
       var contact = new sforce.SObject(“Contact”);
       contact.Id = selectedContactIds[i];
       {!Deelnemer__c.Aanwezig__c} = true ;
       }
}

var saveResult = sforce.connection.update(contactsForUpdate);
location.reload(true);
What am I doing wrong here?