• MuamaEnence MuamaEnence
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
var url = parent.location.href;
var records = {!GETRECORDIDS($ObjectType.Opportunity)};
var updateRecords = [];

if (records[0] == null) { //if the button was clicked but there was no record selected
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
for (var a=0; a<records.length; a++) { //for all records
var update_Opportunity = new sforce.SObject("Opportunity"); //create a new sObject for storing updated record details
update_Opportunity.Id = records[a]; //set the Id of the selected Opportunity record
update_Opportunity.OwnerID= "0050V0000073CQuQAM"; //set the value for Status to 'Unqualified'
updateRecords.push(update_Opportunity); //add the updated record to our array
}
result = sforce.connection.update(updateRecords); //push the updated records back to Salesforce
parent.location.href = url; //refresh the page
}