Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Abort save action using client script

santoshk
Kilo Contributor

Hi,

 

I have created a onSubmit script to validate a field and i want to abort the saving the form if the validation fails. But i am not able to do it using client script. what i am doing is, pop up a error message if validation fails, but as soon as i click on the ok button, it proceed and form saved. Can some one suggest a better way to do that?

 

Thanks in advance,

Santosh Kumar

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Can you share your script?   You should be able to cancel the submission by returning false in the onSubmit function.   Take a look at this wiki article - Client Scripts - ServiceNow Wiki


View solution in original post

3 REPLIES 3

Jim Coyne
Kilo Patron

Can you share your script?   You should be able to cancel the submission by returning false in the onSubmit function.   Take a look at this wiki article - Client Scripts - ServiceNow Wiki


santoshk
Kilo Contributor

Thanks Jim, Its working.



Just missing the last line to return false to the on submit function.


You are welcome.