Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Which executes first ,UI policy action or UI policy script?

Rohith16
Tera Contributor

When runnning ui policies ,which executes first ,whether UI policy action or UI policy script?

27 REPLIES 27

Did you haven anything in UI Policy actions?

Yes. Here is what I just now tested with:

 

RaymondTapper_1-1726174216554.png

 

 

Raymond Tapper
Tera Contributor
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 the following code in the Execute if true section:

 

function onCondition() {
    for (i = 0; i <= 1000; i++) {
        g_form.addErrorMessage('Count ' + i);
    }
    g_form.clearMessages();
    g_form.addErrorMessage('Execute if true');
}

 

 
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.
 
The following code produces a similar result:

 

function onCondition() {
    for (i = 0; i <= 500000; i++) {
		g_form.clearMessages();
    }
    g_form.addErrorMessage('Execute if true');
}​

 

 

This tells me that the script runs before the actions.

Hi @Raymond Tapper  

Thanks but my response was based on what is in ServiceNow ebook. Guess ServiceNow will need to update their ebook 🙂

I completely agree. If it should match the book, then they should fix whatever is wrong.