You need to sign in to do that
Don't have an account?
DTAPADMIN
Can't retreive status from Aggregate SOQL Query in S-Control
I am trying to create a button on the Case the appears as a List button on the Custom Object "Bugs" related list to update the status of the Case. I have code that will updated the status when in the bug but this would update the status from the related list while looking at the Case. My query works but I am not able to assign the status value of the Bug to the variable because it is a nested select statement. Here is my code below, if anyone can tell me how to assign the value returned from the child object in the query to my myObj.Status variable I would appreciate it.
Code:
<html> <head> <script src="/soap/ajax/9.0/connection.js"></script> <script src="/js/dojo/0.4.1/dojo.js"></script> <script> dojo.addOnLoad(init); function init() { var callback = { onSuccess : displayResult, onFailure : displayError }; //This comment is to make sure the code is right var queryResult = sforce.connection.query("SELECT Id, (SELECT Status__c FROM R00N50000001Qr9OEAS) FROM Case WHERE CaseNumber = '{!Case.CaseNumber}'"); var records = queryResult.getArray('records'); if( /Closed/.test ( records[0].Status__c)) { alert("Please close the Case associated with this Bug!"); window.close(); } else { var myObj = new sforce.SObject("Case"); myObj.Id = records[0].Id; myObj.Status = records[0].Status__c; sforce.connection.update([myObj], callback); } } function displayResult(result) { document.getElementById("output-div").innerHTML = "Case successfully updated!"; } function displayError(error) { document.getElementById("output-div").innerHTML = "oops something went wrong ... " + error; } </script> </head> <body> <div id="output-div"></div> </body> </html>