You need to sign in to do that
Don't have an account?
Shamus Kelley 4
Modifying OnClick java button to update additional field during its processing
I'm looking to update the script within this button so that a custom field (i.e. Quote_generated_coun__c) is updated every time the button is clicked. Any help is greatly appreciated!
Here is the current OnClick Java Script that needs modification:
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/21.0/apex.js")}
try{
// check that Opp has the necessary approvals in order to continue
var strCheck = "{!Opportunity.Approval_Required__c}".toLowerCase();
if ( strCheck.indexOf("quote") == -1) {
try{
var result = sforce.apex.execute(
'Opportunity_Buttons', // class name
'createQuote', // method name
{ // arguments
oppIDraw:"{!Opportunity.Id}",
generateQuoteNum:"true"
}
);
if (result[0].success == 'true') {
//window.location = result[0].msg;
window.open(result[0].msg, "quoteWin");
} else alert(result[0].msg);
}
catch(ex){
alert("Error: "+ex);
}
} else alert("No Quote can be generated because Approvals are required");
}
catch (ex) {
alert("Error: " + ex);
}
this script currently generates a new PDF file each time the button is pushed and stores in on the opportunity as a new Attachment. I want to update a number filed (Quote_generated_count__c) on the opportunity record (where the button resides) to keep a count of how many times that button is pushed.
Here is the current OnClick Java Script that needs modification:
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/21.0/apex.js")}
try{
// check that Opp has the necessary approvals in order to continue
var strCheck = "{!Opportunity.Approval_Required__c}".toLowerCase();
if ( strCheck.indexOf("quote") == -1) {
try{
var result = sforce.apex.execute(
'Opportunity_Buttons', // class name
'createQuote', // method name
{ // arguments
oppIDraw:"{!Opportunity.Id}",
generateQuoteNum:"true"
}
);
if (result[0].success == 'true') {
//window.location = result[0].msg;
window.open(result[0].msg, "quoteWin");
} else alert(result[0].msg);
}
catch(ex){
alert("Error: "+ex);
}
} else alert("No Quote can be generated because Approvals are required");
}
catch (ex) {
alert("Error: " + ex);
}
this script currently generates a new PDF file each time the button is pushed and stores in on the opportunity as a new Attachment. I want to update a number filed (Quote_generated_count__c) on the opportunity record (where the button resides) to keep a count of how many times that button is pushed.