+ Start a Discussion
Shamus Kelley 4Shamus 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:

// check that Opp has the necessary approvals in order to continue 
var strCheck = "{!Opportunity.Approval_Required__c}".toLowerCase(); 
if ( strCheck.indexOf("quote") == -1) { 
var result = sforce.apex.execute( 
'Opportunity_Buttons', // class name 
'createQuote', // method name 
{ // arguments 


if (result[0].success == 'true') { 
//window.location = result[0].msg; 
window.open(result[0].msg, "quoteWin"); 
} else alert(result[0].msg); 

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.