function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shashi kanaparthishashi kanaparthi 

Diasbling a on click javascript button after submission

Hi,

i have a button on quotes, the button needs to be disabled after the user clicks once. Let me know if this can be done with JavaScript itself rather than create a VF page.

Code Below :-

{!RequireScript("/soap/ajax/33.0/connection.js")}

var sync = '{!Quote.IsSyncing }'
var conversion = '{!Quote.Conversion_Status__c}'

if( sync == false)
{
alert("Please sync your quote before continuing");
}
else if( conversion == 'Sent')
{
alert("Your Quote has already been sent to CW");
}
else
{
var r = confirm("Note that you can only send Quote to CW one time. Are you sure you want to send?");
}

if(r==true)
{

var quoteID = '{!Quote.Id}'

postParams = {}
postParams.url = 'https://servicesuat.restorationhardware.com:10000/QuoteToCW/' + quoteID
postParams.method = 'GET'
postParams.requestHeaders = {}
postParams.requestData = ''
postParams.requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded' //or another mime-type
postParams.requestHeaders['Content-Length'] = postParams.requestData.length //required for POST
postParams.onSuccess = processSuccess
postParams.onError = processError
sforce.connection.remoteFunction(postParams)


function processSuccess(message)
{ // do something with results¨
alert(message);
window.location.reload();
}
function processError(message)
{ // do something with the error
alert('error');
}}

 
Best Answer chosen by shashi kanaparthi
Shashikant SharmaShashikant Sharma
Hi,

You can not disable it without using a visualforce page. Only thing that you could do is to update a field in Database on first click and query the field from Data Base before doing any further action and show a message to user. 

Thanks
Shashikant

All Answers

Shashikant SharmaShashikant Sharma
Hi,

You can not disable it without using a visualforce page. Only thing that you could do is to update a field in Database on first click and query the field from Data Base before doing any further action and show a message to user. 

Thanks
Shashikant
This was selected as the best answer
Pankaj_GanwaniPankaj_Ganwani
Hi Sashi, 

You can place this.disabled = true after requirescript statement. By doing so, it will be disabled when the button is clicked, but this will reverted to the enabled state once the user refreshes the page. To refrain the user from subsequent clicks, you can follow the aforementioned approach.

Thanks,
Pankaj