How do I make Submit Button clickable only once
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2023 03:35 AM
Currently, submit button can be clicked mutliple times which results in creating multiple cases. Need to make it clickable once at a time. Please suggest. Thanks in Advance....
HTML code:
</div>
<div class="col-md-3 button-vertical-center" >
<!--<div class="page0Submit" ng-click="c.submitButton()">Submit</div>-->
<button type="button" class="page0Submit" ng-click="c.submitButton()">Submit</button>
</div>
</div>
Client Controller:
c.submitButton = function() {
var obj = {};
obj.action = 'create_case';
c.server.get(obj).then(function (response) {
obj.action = undefined;
console.log("newly created case: "+response.data.insertedID);
window.location.href = window.location.href+'&sysparm_recordid='+response.data.insertedID;
});
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 08:53 PM - edited 01-07-2023 08:54 PM
I am not sure about the code given above, but if your requirement is to disable a Submit button a ServiceNow record in form view, read below:
Add a custom boolean field to the form, such as x_custom_app_is_submitting, and set its default value to false.
In the client script on the form, use the following code to disable the submit button when it is clicked:
function disableSubmit() {
g_form.setValue('x_custom_app_is_submitting', true);
g_form.setDisabled('sysverb_insert', true);
}
- In the onSubmit client script of the form, use the following code to check the value of the x_custom_app_is_submitting field and re-enable the submit button if necessary:
if (g_form.getValue('x_custom_app_is_submitting')) {
g_form.setValue('x_custom_app_is_submitting', false);
g_form.setDisabled('sysverb_insert', false);
return false;
}
This will disable the submit button after it is clicked, and re-enable it once the form is submitted. This will prevent multiple cases from being created if the submit button is clicked multiple times.
Kindly mark the response as Correct or Helpful.
Cheers,
Anish