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

JS Onclick Button: Query to update other child records? (Detail Page Button)
Is it possible to update multiple records from a detail page button with the help of a query? I know it's possible to do this with a list, but here's the scenario:
User recommends child record - changes a status and a boolean. Other child records also need to have their boolean(s) toggled to true. However, the button is on the detail page - NOT a list.
The following works great:
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} var newRecords = []; var thisP = new sforce.SObject("Proposal__c"); thisP.id = "{!Proposal__c.Id}"; thisP.Status__c = "Awarded"; thisP.test__c = true; newRecords.push(thisP); result = sforce.connection.update(newRecords); location.reload(true);
However, I'm trying to introduce this, where Ideally i'd like to update other child records (with the same parent (Order__c) lookup)
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} var newRecords = []; var otherP = sforce.connection.query("Select Id from Proposal__c where Order__c = '{!Proposal__c.OrderId__c}' "); otherP.test__c = true; newRecords.push(otherP); //Add all other records to array? var thisP = new sforce.SObject("Proposal__c"); thisP.id = "{!Proposal__c.Id}"; thisP.Status__c = "Awarded"; thisP.test__c = true; newRecords.push(thisP); //Add current detail page record to array result = sforce.connection.update(newRecords); location.reload(true);
here to go
Thanks,
Bala
All Answers
here to go
Thanks,
Bala
Almost. I'm goign to try to tweak it a little bit but,
I'm not trying to change all related records status to "Awarded". Just the single one (from where the button click was initiated).
However, I need to change ALL (including one from where button click was initiated) to test__c = true;
I think this might be of some help though, i'll definitely poke around.
Working
Its nice to heard that it works for you
Thanks,
bForce
Thanks again bForce. I have another issue now - it's no fault of the button - but I can't seem to use it for a named portal user.
http://boards.developerforce.com/t5/AJAX-Toolkit-S-Controls/Named-Customer-Portal-JS-onclick-remote-invocation-failed/td-p/430607
Basically, we have authenticated portal users logging in, and this is a button for them. I've tested it thoroughly with an internal user (myself) and it works fine. however...when a portal user (with API enabled) tries to hit the button.... I get a weird error.
Remote invocation failed, due to: (Lots of html markup,seems like my generic error page)
then...
Page Not Found: /portal/services/Soap/u/24.0
And I know that site users can't use the API - can named portal users not as well?
Figured part of this out...
Needed to add the second line.
However, it looks like named customer portal users do not have access to the SOQL in the button? I'm able to make edits on the page the button is clicked from...however the boolean isn't toggled on (any) of the records.
ughhhhh. I'm retarded.
Didn't enable write permission to that field for the portal user. All is well.