Which executes first ,UI policy action or UI policy script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2019 07:51 AM
When runnning ui policies ,which executes first ,whether UI policy action or UI policy script?
- 21,899 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 03:36 AM
UI Policy action executes before the UI policy script.
You can test it by creating UI policy on the form for a particular field, e.g. category on incident form. In that, write UI policy script and create one UI Policy action. Then, go to Preferences->Developers->Click on JS Log and Field watcher, make it true. Then, you can Field Watch the category on incident form. You will see the execution order clearly in Field Watcher.
You can refer to the screenshot attached herewith.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 11:06 AM
Hi Rohith, best way to answer this would be to create a policy with script and return true/false from the script. If policy actions are still executed, you will understand that actions are based on the outcome of script. Thus order would be:
Policy Script >> Policy Actions.
But if this does not happen, you conclude the opposite.
The documentation say
UI Script
Client Script
UI policy.
But its not very clearly written whats happen in UI policy. We know for sure that condition dictate policy actions, and to my understanding policy scripts is just an extension of conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 03:10 AM
UI policy Action first and then UI policy script.
Please refer: https://youtu.be/TptpAXlLT10?si=BmXX4_ybR4RYZdVA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2025 11:19 AM
Execution Order in UI Policies
When running UI Policies in ServiceNow, the execution order is:
UI Policy Conditions – First, ServiceNow checks if the conditions of the UI Policy are met.
UI Policy Actions – If the conditions are met, UI Policy Actions (e.g., setting fields mandatory, visible, or read-only) execute first.
UI Policy Scripts – After UI Policy Actions execute, any associated UI Policy Scripts run.
Why Does UI Policy Action Execute First?
- UI Policy Actions are declarative (they directly modify UI elements).
- UI Policy Scripts allow for more complex logic, so they execute after actions to override or extend behavior if needed.
Example Case
Let's say you have a UI Policy:
- Condition: If priority == 1
- Action: Set description field to mandatory
- Script: Log a message in the console
When triggered:
The description field becomes mandatory first (UI Policy Action).
Then, the UI Policy Script executes (e.g., logs to console).
Conclusion
UI Policy Actions execute first, followed by UI Policy Scripts.
This ensures that UI behavior changes happen before any custom logic runs.
Hope this helps! Let me know if you need further clarification.
(If you found this helpful, don’t forget to give a thumbs-up!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2025 05:44 PM
Hi,
UI policy script executes first, and then the action.
Here's how you can test it:
Create a simple UI policy on any form, provide an alert statement in the script, 'Execute if true' part, save the UI policy. Then add a new action to make a field mandatory.
When the UI policy conditions are met, you can see that first the alert statement is shown and after that the field is made mandatory.
So that confirms, in a UI policy, script is executed first and then the action.
Thanks,
Gopikrishnan

