You need to sign in to do that
Don't have an account?
Shamus Kelley 4
Update OnClick java script to populate a number filed (i.e. counter) to show how many times the button is pushed?
Hello -
I need to update the javascript within this button so that a custom field (i.e. counter__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);
}
I need to update the javascript within this button so that a custom field (i.e. counter__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);
}
You can create a checkbox field for this onm Opportunity default will be false, when button is clicked checks it's value to true. So that way you don't need to maintain counter for button.
Hope this helps.
You can also disable your custom button and reenable it after the process completes on standard detail page , so that no one will able to click multiple times. You need to find the element id by using inspect element of browser using right click . Below link will give you an idea about disabling the button on standard layout.
https://salesforce.stackexchange.com/questions/112365/disable-custom-button-in-standard-page-layout
Hope this helps.
Shamus,
Actually i was saying that you can update a custom boolean field to true on custom javacript button , during this process disable the button so that way your field will update the value to true and user won't be able to click multiple times during that process , when process of updation completes , you can undisable the button.