Skip to content

Instantly share code, notes, and snippets.

@jaspreetsidhu
Created May 2, 2019 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaspreetsidhu/0e1c8d9756a09bac7828153dc101761c to your computer and use it in GitHub Desktop.
Save jaspreetsidhu/0e1c8d9756a09bac7828153dc101761c to your computer and use it in GitHub Desktop.
Old Javascript button
{ !REQUIRESCRIPT("/soap/ajax/31.0/connection.js") }
var myquery = "SELECT Id, Name, Sent_to_Epicor__c, Contact_ID_Lookup__c FROM Opportunity WHERE Id = '{!Opportunity.Id}' limit 1";
result = sforce.connection.query(myquery);
records = result.getArray("records");
var myOpp = records[0];
var updateOpp = new Array();
var confirmMsg = 'We are in the process of sending your quote to Epicor! Please note: this quote has only been successfully posted to Epicor once the Epicor ID and Date Created In Epicor fields are populated in the Salesforce Opportunity.'
if (myOpp.Required_Opp_Fields_To_Quote__c == 'false') {
alert('Please check the required fields before quoting');
}
else {
myOpp.Sent_to_Epicor__c = true;
updateOpp.push(myOpp);
result = sforce.connection.update(updateOpp);
if (result[0].getBoolean("success")) {
alert(confirmMsg)
window.location = "/" + "{!Opportunity.Id}";
} else {
alert('Could not Export : ' + result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment