- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
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 .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
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?
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
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?
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi,
If you are using one business rule with or condition then switching between option A and B will not trigfer the UI Action to react.
Instead you can create two UI policies one for Option A or Option B. Alternatively you can also use Client Script which run on change of the field value
Palani
