You need to sign in to do that
Don't have an account?
JackieDoan
Attempting to use record criteria, rather than checkbox selection, for list button
I have created a custom list button, which executes javascript. Instead of using GETRECORDIDS, I'd like to use record criteria (any related records where status = 'New'). I attempted to modify the code behind my button to accept the criteria using the sforce.connection.query, but keep getting errors.
Here's the existing code:
{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")} var url = parent.location.href; var records = {!GETRECORDIDS($ObjectType.Contact)}; var updateRecords = []; if (records[0] == null) { alert("Please select at least one record to update."); } else { for (var a=0; a<records.length; a++) { var update_Contact = new sforce.SObject("Contact"); update_Contact.Id = records[a]; update_Contact.Status__c = "Transmit"; updateRecords.push(update_Contact); } result = sforce.connection.update(updateRecords); parent.location.href = url; }
Can anyone give me a suggestion on how to modify this so I can bypass the checkbox selection and use status of "New" to execute the code?
Thanks!
sfdcfox
You'd have to replace the GETRECORDIDS function in the standard library with a custom function to do it the way you're trying to. I'd suggest instead that you simply grab the current record's ID, then perform a sforce.connection.query to find the relevant records (which may not even appear in the list at the time of the button click).