Making fields mandatory after clicking UI action and change the state

shaik23
Tera Expert

Hello experts.

Any help appreciated. 

 

Add two fields

Expedite_code (u_expedite_code)

  • Employee Relations

  • Regulatory Compliance

  • Security

Expedite_justification (u_expedite_justification)

Create UI action link “Expedite” (available to demand coordinators group, and the assigned demand manager)

This will ask for reason code and text (both required) and move the demand to “Approved”.

 

 

 

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @shaik23 ,

 

Try the UI Action as shown in the screen shots below.

  1. In the condition field change the demand coordinators group name as per your configuration.
  2. Script:

 

 

function moveToApproved(){
	g_form.setValue("state", "8");
	g_form.setMandatory("u_expedite_code", true);
	g_form.setMandatory("u_expedite_justification", true);
	gsftSubmit(null, g_form.getFormElement(), 'state_demand_expedite');
}

if (typeof window == 'undefined')
   updateAndRedirect();

function updateAndRedirect() {
	current.setValue("state", "8");
    current.update();
    action.setRedirectURL(current);
}

 

 

 

AnveshKumarM_4-1695049414476.png

AnveshKumarM_6-1695049539256.png

 

Please mark my answer helpful and accept as solution if it helped you 👍✔️

 

 

 

 

Thanks,
Anvesh

View solution in original post

4 REPLIES 4

AnveshKumar M
Tera Sage
Tera Sage

Hi @shaik23 ,

 

Try the UI Action as shown in the screen shots below.

  1. In the condition field change the demand coordinators group name as per your configuration.
  2. Script:

 

 

function moveToApproved(){
	g_form.setValue("state", "8");
	g_form.setMandatory("u_expedite_code", true);
	g_form.setMandatory("u_expedite_justification", true);
	gsftSubmit(null, g_form.getFormElement(), 'state_demand_expedite');
}

if (typeof window == 'undefined')
   updateAndRedirect();

function updateAndRedirect() {
	current.setValue("state", "8");
    current.update();
    action.setRedirectURL(current);
}

 

 

 

AnveshKumarM_4-1695049414476.png

AnveshKumarM_6-1695049539256.png

 

Please mark my answer helpful and accept as solution if it helped you 👍✔️

 

 

 

 

Thanks,
Anvesh

Working perfectly 👍

@shaik23 I'm glad this helped 😀👍

Thanks,
Anvesh

Hi @AnveshKumar M ,

 

I have a similar issue. If you can help me here please? State does not change.

https://www.servicenow.com/community/spm-forum/a-field-should-be-mandatory-to-fill-in-when-clicked-o...

 

Thanks you for the help!