Create a business rule / onsubmit script to restrict the form from updating/submitting

Uttam Sai
Tera Contributor

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 

14 REPLIES 14

@Uttam Sai write below code in on submit client script

 

if(g_form.getValue('<ABORT SUBMIT FIELD NAME>')){

return false; //This will abort the submit

}

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Hi Prasath,

 

I have a state field and when the user from non assignment group wants to complete it i need to restrict them to complete the task . I want to write a before update BR . Can you give me the sample BR for this

jaheerhattiwale
Mega Sage
Mega Sage

@Uttam Sai Create a new field called "Abort Submit" (true/false) type. Keep it on the form but hide it in onload client script.

 

In the on change client script you have set the "Abort Submit" field to true if you show message else set to false.

 

Create a on submit client script and check if "Abort Submit" is true or false.

if its true

return false; to abort action

 

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Hi @jaheerhattiwale ,

 

Could you please provide the  onsubmit script to check if "Abort Submit" is true or false. and then abort action

@Uttam Sai write below code in on submit client script

 

if(g_form.getValue('<ABORT SUBMIT FIELD NAME>')){

return false; //This will abort the submit

}

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023