How to change state option based on UI action

Pravalika
Kilo Contributor

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

4 REPLIES 4

erik_brostrom
Mega Guru

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

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.

find_real_file.png

Allen Andreas
Administrator
Administrator

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!

satya satya
Giga Contributor

Hi,

this is help for you

g_form.setValue('state', ?); //replace ? with the value of the field you wish to change it to