UI policy - Condition issue

Mike49
Tera Contributor

I have a simple UI Policy that shows a field message when the user selects Option A or Option B, a field message appears. 

If the user selects Option A, the field message shows as expected. 

However, if the user selects Option B after Option A was select first, the field message disappears.  I have no code that clears all field messages.

 

It's behaving as if the condition is evaluating to false but it should be evaluating to true .

 

 

2 ACCEPTED SOLUTIONS

Hemanth M
Tera Sage

Hi @Mike49 ,

I have observed this, it wouldn't execute the 'if' condition script if a condition is met already, unless it executes the 'else' condition once


Option A and Option B will not work.
Option A, Option C, and again Option A or B works


Why don't you try an onChange client script instead?

 

 

View solution in original post

Sarthak Kashyap
Mega Sage

Hi @Mike49 ,

 

Please check reverse if false is checked and you can add below script 

function onCondition() {
	alert("Running");

    var val = g_form.getValue('category');

    g_form.hideFieldMsg('category'); // clear old message

    if (val == 'inquiry' || val == 'software') {
		alert("Running Val = " + val);
        g_form.showFieldMsg('category', 'Your message goes here', 'info');
    }


}

 

 

 

If this will not work you can also use client script for your problem which runs on change of your field and add below code 

function onChange(control, oldValue, newValue) {
    g_form.hideFieldMsg('your_choice_field');

    if (newValue == 'Option A' || newValue == 'Option B') { // backend value of option A& B
        g_form.showFieldMsg('your_choice_field', 'Your message goes here.','info');
    }
}

 

Please mark my answer correct and helpful if this works for you
Thanks and Regards,

Sarthak

 

 

View solution in original post

6 REPLIES 6

nawalkishos
Kilo Sage

Hi @Mike49 ,

If Reverse if false is enabled, then when the UI Policy condition evaluates to false

Please review in your case !

 

If you found my response helpful, please mark it as helpful and accept it as the solution.

Thank you
Nawal Singh

Hi Nawal,

 

Appreciate the info.  I have Reverse if false enabled and the behavior remains.  

 

If the dropdown goes from --None-- to Option A, the field message shows.

Then, if the dropdown changes from Option A to Option B, the field message disappears.  

 

The Condition in the UI Policy is variableA is one of Option A, Option B.

 

Hemanth M
Tera Sage

Hi @Mike49 ,

I have observed this, it wouldn't execute the 'if' condition script if a condition is met already, unless it executes the 'else' condition once


Option A and Option B will not work.
Option A, Option C, and again Option A or B works


Why don't you try an onChange client script instead?

 

 

Mike49
Tera Contributor

Hi Hemanth,

 

That's the confirmation I needed to read is that it won't execute if it's already been met.  I thought UI Policy was the right way to do it but I'll have to use an onChange client script.

 

Appreciate the help.