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.

Having a UI Action validate fields before save.

ccajohnson
Kilo Sage

I have made a UI action button which changes the status of a record, then saves the record. Unfortunately any validations that should occur on save do not happen and we have a record with required fields not filled out that are not being reported on.

current.state='3'; //changes status to pending
current.u_status_detail='Review';
current.update();
action.setRedirectURL(current);

We use a client script to do the validation for this record state. I would like to be able to call this client script within the UI action rather than recreating the entire validation routine in the UI Action.

Please let me know if there is a way to force validation before the UI action saves.

5 REPLIES 5

Thank you Matt, I was able to leverage the dual functionality of a UI Action with my client scripts. The important step that I was missing was calling the submit using the syntax:
gsftSubmit(null, g_form.getFormElement(), '');

...then calling the rest of the UI Action by using the same Action name used in that line of code.