Create a business rule / onsubmit script to restrict the form from updating/submitting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 08:00 PM
Hi Team,
I am using an Onchange client script on outage form to show error message on two fields. But the issue is that i am able to save or submit the form despite the error. Can we create a business rule / onsubmit client script to restrict the form from updating/submitting if there are field error message .Could you please let me know what alternate ways we can try to achieve this.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 08:03 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 08:13 PM
Hi @Uttam Sai,
You can create before business rule which will show the error message and abort the save action.
Or else use the onSubmit client script to return false.
Refer: https://servicenowguru.com/scripting/stopping-record-submission-servicenow/
If still wish to use the onchange client script. you can set the field value back to previous value and show the message for the same. This can restrict the field value change. Make sure that this changes does not goes on loop in the client script.
Let me know if it helped.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 08:14 PM - edited 01-05-2023 08:16 PM
Hello @Uttam Sai ,
Field messages gets displayed but it wont stop you in saving the record , if you want to do some validations use Submit client script and use "return false" to abort the submission
Ex : if(a=b){
return true; // allows saving record
else
return false // aborts saving record
==================================
Also you can use before update BR and do validation and if it return false use current.setAbortAction(true); to save the record
Regards,
Shyamkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 08:41 PM
Hi @Uttam Sai
We can use the business rule and setAbortAction() method to restrict the form submission. If you explain your requirement clearly I can provide you with the script.
Please mark my answer as helpful, if it helped you accordingly!
Thanks,
Hari