How to change state option based on UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 07:37 AM
My Requirement is for example : when i click on awaiting approval button(UI ACTION BUTTON) in the form then state field should change to awaiting approval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 07:43 AM
In the UI action, set the state value:
Server:
current.state = <value>;
current.update();
Or client...
if(typeof window == 'undefined')
updateState();
function updateState() {
current.state = <value>;
current.update();
action.setRedirectURL(current);
}
Recommend reading up on UI actions:
https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/list-administration/concept/c_UIActions.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 02:23 AM
Hi,
when we click on Published button the architecture design field and integration design field has to be mandatory and the form should not be saved and state should not be in published until those both fields are true(CHECKED)
can you please let me know how to script in UI Action.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 07:43 AM
Hi,
You can do this by checking the "client" box on that UI Action settings and then use script as:
g_form.setValue('state', ?); //replace ? with the value of the field you wish to change it to
This would make the change in the client and that's it.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 03:29 AM
Hi,
this is help for you
g_form.setValue('state', ?); //replace ? with the value of the field you wish to change it to