The CreatorCon Call for Content is officially open! Get started here.

Which runs before out of client script and ui policy?

saini
Tera Expert

We know that client script runs before UI policy.

If the client script is running onSubmit and ui policy onLoad, then which one runs first and why?

 

Thanks

2 REPLIES 2

Filipe Cruz
Kilo Sage

Hello saini,

I'm not fully getting your question.
The UI policy runs when the trigger conditions are met!

If there are no trigger conditions, then it runs on load.
The onSubmit Client script runs when the form is submitted.

In principle, in this scenario, the ui policy will run first!


Please, if this answer is relevant for you, please mark it as correct and helpful.

Thanks,

Filipe

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Saini,

Not sure of the question.

Normally, UI Policy that's being started onLoad will run first if the condition is met. It would be loaded when the form loads and executed when there is a change is value of the field that meets the condition while the form is being entered.

Is the question about trying to change the field value onSubmit and whether UI Policy would run after onSubmit? In what kind of case would this occur? If the value of the field is to be changed after onSubmit, it would be better to use business rule instead of trying to do it with UI Policy.

If there is a script in UI Policy that needs to be executed, it would be better to combine it in onSubmit.

 

Nevertheless, I've tried it.

  1. Created fields named field1, field2, and field3.
    set default value on field 3 to be "initial value"
  2. onSubmit script
    function onSubmit() {
        alert("onSubmit");
        g_form.setValue('field2', "test");
    }​
  3. UI Policy
    When to apply: field2 is "test"
    Execute if true script:
    function onCondition() {
        g_form.setValue('field3', "changed by UI Policy");
    }​

     

Execution result:

In field2, I've entered "dummy field".

find_real_file.png

When I look at values of variables in Requested Items, I see that field3 has value "changed by UI Policy". This implies onSubmit is executed before UI Policy because otherwise, UI Policy won't be executed and value of field3 would remain as "initial value".

find_real_file.png