You need to sign in to do that
Don't have an account?
DTAPADMIN
How to see if a returned value contains a word
I have an S-control that updates the status of a case based on the status of a custom Bug object. What I want to do now is check to see if the status of the Bug that is returned contains the word "Closed" if it does I want to send a message asking the user to Close the associated Case. Here is my current code:
Code:
Any help or suggestions would be greatly appreciated.
<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 }; var queryResult = sforce.connection.query("SELECT Case__r.Id, Status__c FROM SFDC_Bug__c WHERE Name = '{!SFDC_Bug__c.Name}'"); var records = queryResult.getArray('records'); var myObj = new sforce.SObject("Case"); myObj.Id = records[0].Case__r.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>
Any help or suggestions would be greatly appreciated.
Thanks
if ( /Closed/.test ( records[0].Status__c ) ) {
// do a message
}
I use a cheat-sheet from www.visibone.com which describes regular expressions