Correct answer is A. I didn't find any definite statements about order in the docs. However in the link, quoted for this question, there are two opposite responses. One, which takes UI Policy Actions first and UI Policy Scripts second, was marked helpful by ServiceNow and Expert(s)
A is correct, verified.
Created UI policy on incident form, action set's cmdb_ci field as mandatory and script as not. result, field was not mandatory.
The answer is A
Actions execute first: When a UI Policy is triggered, the Actions are applied first. This ensures that the form is updated (fields are shown, hidden, made mandatory, etc.) before any custom scripts are run.
Scripts execute after Actions: Once the Actions have been applied, the UI Policy Scripts are then executed. This allows the script to work with the form in its updated state.
In ServiceNow, when a UI Policy is triggered, its actions (such as setting fields to mandatory, visible, or read-only) are executed before any scripts associated with the UI Policy are run.
The Scripting in ServiceNow Fundamentals course section called Catalog Client Scripts and Catalog UI Policies which is found in the student instance has a KBA #KB86753O9 that states "UI Policy Actions execute before UI Policy Scripts".
This video goes over Answer A - https://www.google.com/search?client=opera&q=UI+Policy%27s+Actions+execute+before+the+UI+Policy%27s+Scripts&sourceid=opera&ie=UTF-8&oe=UTF-8#fpstate=ive&vld=cid:63e72bd4,vid:TptpAXlLT10,st:0
C
UI Policy’s Scripts execute before the UI Policy’s Actions (Option C): This statement is accurate. When a UI Policy is triggered, its script runs first. The script evaluates conditions and performs any necessary modifications. If the conditions are met, the associated actions (such as hiding fields or setting field values) are then executed.
Just tested in my PDI.
Sample example:
1) on incident form write UI policy when state changes to closed; make short description as mandatory from UI policy action
2) from UI policy script execute if true; use below script
g_form.setMandatory('short_description', false);
Answer is A.
I tested this on the incident form in a Vancouver PDI by modifying the "Fields set to mandatory for all states" UI policy.
I changed the "When to Apply" condition to when the state was "In Progress"
I enabled "Run scripts" and added code in the "Execute if true" section
**I keep getting bad gateway errors when I try to submit with the code**
When the form loads, the caller and short descriptions fields are not mandatory. When I select "In Progress" for the state, after about 5 seconds the caller and short description fields become mandatory.
This tells me that the script runs before the actions.
The answer is C
In ServiceNow, UI Policies are used to dynamically change the behavior of form elements based on certain conditions. A UI Policy consists of both Scripts and Actions.
Scripts: These are JavaScript code snippets that execute when the conditions specified in the UI Policy are met. They are typically used for more complex logic and calculations.
Actions: These are predefined operations that can be applied to form elements when the conditions are met. Examples include showing or hiding a field, making a field mandatory, or setting a default value.
The correct order of execution is that the Scripts execute before the Actions. The JavaScript code in the Scripts section is evaluated first, and based on the results, the corresponding Actions are then executed.
So, option C is the correct statement.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
nsmcan
Highly Voted 3 years, 1 month agoHaikz
Highly Voted 2 years, 5 months agoRoadtoCad
Most Recent 2 months, 4 weeks agoDKey
3 months, 3 weeks agosahithi2004
4 months, 1 week agoCodingAmo
5 months agojutorri
5 months ago51f8ce8
5 months, 1 week agochrisRY
5 months, 3 weeks agogeorgeg4
6 months, 1 week agogeorgeg4
6 months agoChanti1243
7 months, 2 weeks agoChecwes
8 months, 1 week agomanikanta_gnbv
8 months, 1 week agoMacGyver4th
9 months, 3 weeks agoevoken
10 months, 1 week agoD_Ogi
10 months, 1 week agozoro69
12 months ago