Catalog UI Policy with Rich Label in Employee Center is visible for invalid Single Line Text input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi Team,
I am facing an issue with a Catalog UI Policy in Employee Center.
Requirement:
- I have a Course Cost variable of type Single Line Text (there is no Integer/Decimal variable type available).
- I have a Rich Label variable (retention policy) and a checkbox (retention consent).
- The Rich Label and checkbox should be displayed only when:
- Course Cost >= 10001
- Requested For Location contains Asia
My Catalog UI Policy condition is:
- course_cost >= 10001
- Requested For Location contains Asia
The UI Policy has:
- On Load = Checked
- Reverse if False = Checked
The UI Policy Actions make both the Rich Label and checkbox Visible = True.
I also have:
- An onSubmit Catalog Client Script that validates the Course Cost and prevents submission if the value is not numeric.
- An onChange Catalog Client Script that calculates the retention period based on the Course Cost.
Issue:
If I enter an invalid value such as abc or hrdfbdfdh in the Course Cost field, the Employee Retention Policy (Rich Label) still becomes visible, even though the value is not numeric and the UI Policy condition should not evaluate as >= 10001.
Has anyone experienced this behaviour with Rich Label variables and Catalog UI Policies in Employee Center?
- Is this a known limitation with Rich Label variables?
- Is there a recommended way to control the visibility of a Rich Label based on a numeric value entered in a Single Line Text variable?
Any suggestions would be appreciated. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @aparnaravi ,
1.Update the catalog variable,Under Type specification related list ,make validation regex = number and save record.
2.Now The input accept only numbers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Thank you for the information. I made the suggested changes, and now when I enter characters in the Course Cost field, it correctly identifies the value as invalid (not a number).
However, I still have an issue. I have created a Catalog UI Policy to display the Employee Retention Policy only when the Course Cost is greater than 10000. Despite this, if I enter non-numeric characters (for example, abc), the Employee Retention Policy is still displayed.
Thank you for the information. I made the suggested changes, and now when I enter characters in the Course Cost field, it correctly identifies the value as invalid (not a number).
However, I still have an issue. I have created a Catalog UI Policy to display the Employee Retention Policy only when the Course Cost is greater than 10000. Despite this, if I enter non-numeric characters (for example, abc), the Employee Retention Policy is still displayed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
58m ago - last edited 56m ago
Hi @aparnaravi,
Use onChange Client Script for your requirement instead of UI Policy. Or add the integer parsing code in the UI Policy script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var cost = parseInt(newValue, 10);
var location = g_form.getDisplayValue('requested_for_location');
var show = !isNaN(cost) &&
cost > 10000 &&
location.indexOf('Asia') > -1;
g_form.setDisplay('retention_policy', show);
g_form.setDisplay('retention_consent', show);
}
You can parse integer from string text and check if your condition matches or not.
Please Accept this response as Solution if it assisted you with your question & Mark this response as Helpful.
Kind Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
my thoughts
-> use onChange catalog client script and convert the value to integer and then compare and have your logic
-> use onSubmit script as it is
create new onChnage script as this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
var cost = parseInt(newValue, 10);
var location = g_form.getValue('requested_for_location') || '';
var shouldShow = !isNaN(cost) && cost >= 10001 && location.indexOf('Asia') > -1;
g_form.setVisible('retention_policy_label', shouldShow);
g_form.setVisible('retention_consent', shouldShow);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader