Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Establish a connection to the API,
- // using the current session ID
- {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
- sforce.connection.sessionId = "{!$Api.Session_ID}";
- // This button was created to attempt validation of an Account.
- // All we have to do is instantiate the account in JavaScript,
- // and set the IsValidating__c field to true, which we assume
- // will set off the desired validation rule
- var account = new sforce.SObject("Account");
- account.Id = "{!Account.Id}";
- account.IsValidating__c = true;
- // Attempt to update the account record.
- // This requires the account to be placed in an array, and
- // the update results will similarly be given back in an array
- var results = sforce.connection.update([account]);
- // Examine the results to see whether our update was successful.
- // If it was, then all is well. We will assume there is an associated
- // workflow rule that will clear the IsValidating__c checkbox.
- if (results[0].getBoolean("success")) {
- alert("Validation succeeded!");
- }
- else {
- alert("Validation failed...");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement