Which one will runs first UI Policy action or UI Policy script

Arjun25
Tera Contributor

I believe UI Policy Scripts run first am i right????

28 REPLIES 28

unknown user
Mega Expert

Earlier UI Policy executed before UI Actions but according to the new Quebec release

A UI Policy's Actions execute before the UI Policy's Scripts.

According to "the new Quebec release" WHERE?

Please provide a link to your source.  Thank you. 

Saiganeshraja
Kilo Sage

UI policy Action executes first, UI  policy Script executes next.

Allen Andreas
Tera Patron

Hi all 🙂

I know this post is old, but there's a lot of replies and there's still some people questioning things, so I'll try and provide my 2 cents from the testing I've done.

This is current as of Tokyo and still seems to be the way I've always thought it executed, but it's:

  • Client Script
  • UI Policy Condition evaluated
  • UI Policy Advanced Script executed
  • UI Policy Actions (related list) executed

This was tested using a very simple process, such as using an alert in the client script, a UI Policy with no condition at all, an alert in the UI Policy advanced script, and then setting a field to mandatory via the UI Policy Actions related list.

The client script alert showed first, then UI Policy condition was evaluated, the UI Policy advanced script for true executed which showed its alert, then the field become mandatory per the settings in the UI Policy Actions related list.

The bolded part above is relevant to this specific post, although I did cover more, I wanted to bring the focus back to the bolded part for this thread.

So @michael groth if you don't mind, you can verify yourself, but I think people seeing a ServiceNow employee marking replies to the contrary, as helpful, is contributing to some of the confusion in this 3 year old post that is still having people question things today. If you can verify on your side and perhaps endorse the Correct answer, that could help the Community 😉

The above execution process I've mentioned has been that way for years and years.

Thank you!

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

GeoffreyOptumOp
Tera Expert

Step 1.  Configure UI Actions to set some custom fields to NOT MANDATORY AND NOT READ ONLY.
(...Using brand new custom form fields so we know that no other logic is affecting them...)

find_real_file.png

Step 2.  Configure Script block to set those same fields to MANDATORY and READ ONLY.

find_real_file.png

Step 3.  Verify that the script ran successfully and see the results.

find_real_file.png

Fields end up being set to MANDATORY and READ ONLY.  That tells us that the UI Actions happened first, and THEN the Script ran and changed the settings to whatever it wanted.

Conclusion:  UI Actions Run before Script.

 

@Arjun @Allen Andreas Agree?