Having a UI Action validate fields before save.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2011 09:40 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2011 09:47 AM
i think you should click client option and then copy the code of ur validation(client scripts validation) in script area and wrap this in a function say validate(){code}.
And then in onclick juist pass call to validate function validate();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2011 04:31 AM
I think your point is correct.. but still the whole purpose wouldnt be served. since we select the client option it wont allow us to use any of the server side object like action.setRedirectURL or current.update().

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2011 01:29 PM
That seems to be the easiest way to go, but I do not want to have to maintain the validation code in two locations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2011 02:14 PM
http://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/