You need to sign in to do that
Don't have an account?

JavaScript List button
Hi all,
I have a JavaScript List button that I want to use in Contacts related list of Account object. This button is supposed to grab and alert the user with Email addresses of contacts selected.
My code works whenever a signle record is selected, but it throws a "INVALID_QUERY_FILTER_OPERATOR" whenever multiple contact records are selected.
Need help pls.
{!RequireScript("/soap/ajax/20.0/connection.js")}
var contactRecords= {!GETRECORDIDS($ObjectType.Contact)};
var contactEmails = " ";
var ccEmails = "p4=salesforce@tionetworks.com&";
if (contactRecords.length ==0) {
alert("Please select at least one Contact record.");
} else {
var result = sforce.connection.query("select Name, Id, Email from Contact Where Id ='" +contactRecords+ "'");
var records = result.getArray("records");
for (var i=0; i< records.length; i++) {
var email = records[i].Email;
}
contactEmails += email;
alert("records:"+contactEmails);
}
Any help is appreciated.
Thank you,
Behzad
Hello JNic,
You need to enclose the Collected Ids in a specific standard format.
With GETRECORDIDS you get Ids as a, b, c
But in dynamic query you need to have ids as ('a', 'b', 'c')
Following code might help you in understanding more clearly.
Please mark it as resolved if its what you were looking for, It might help other developers facing similar issue.
All Answers
Hello JNic,
You need to enclose the Collected Ids in a specific standard format.
With GETRECORDIDS you get Ids as a, b, c
But in dynamic query you need to have ids as ('a', 'b', 'c')
Following code might help you in understanding more clearly.
Please mark it as resolved if its what you were looking for, It might help other developers facing similar issue.
This is very close to what I need, but I am still stuck.
I wrote this code for a button used in a single record and it works. however I need this same procedure to work for a multi select list button. I tried all options, but cannot get my head around it.
CODE
params = {
"FirstName" :'{!Lead.FirstName}',
"Product": "WXXXX",
"LastName": '{!Lead.LastName}',
"Email": '{!Lead.Email}',
"Telephone": '{!Lead.Phone}',
"Company": '{!Lead.Company}',
"ReceiveNewsletter": true,
"ReceiveOtherNews": true,
"IsReseller": false,
"DoNotDistribute": false,
"DoNotContact": false,
"IP": "1.1.1.255",
"REDIRECT": "https://eu2.salesforce.com/00Q/o"
};
var form = document.createElement('form');
form.setAttribute('method', 'post');
form.setAttribute('action', 'https://MY.END.POINT.URL.com');
form.setAttribute('target', '_self');
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement('input');
hiddenField.setAttribute('type', 'hidden');
hiddenField.setAttribute('name', key);
hiddenField.setAttribute('value', params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();