Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This Javascript should grab the Id URL parameter, and update the "Taken By" field, setting it to empty.
- //This code is designed to be placed in a button on the Feature__c detail page.
- {!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit
- var url = parent.location.href; //string for the URL of the current page
- var recordOnPage = window.location.href.replace('https://' + window.location.host + '/', '');
- var updateRecords = []; //array for holding records that this code will ultimately update
- if (id == null) {
- alert("Please select at least one record to update."); //alert the user that they didn't make a selection
- } else { //otherwise, there was a record selection
- var update_Feature = new sforce.SObject("Feature__c"); //create a new sObject for storing updated record details
- update_Feature.Id = recordOnPage; //set the Id of the selected record
- update_Feature.Taken_By__c = ""; //set the value for Taken By field to an empty string
- updateRecords.push(update_Feature); //add the updated record to our array
- console.dir(updateRecords);
- result = sforce.connection.update(updateRecords); //push the updated records back to Salesforce
- //ERROR: Refused to set unsafe header "User-Agent"
- console.dir(result);
- //parent.location.href = url; //refresh the page
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement