Issue with Catalog UI Policy condition and numeric input handling

RajeshEdaguttu
Kilo Contributor

I have created a Catalog UI Policy where the condition is:

If Number of Attendees ≥ 10, then:

Make Estimated Budget field visible

Set its value to 10000

However, I am facing an issue:

Even when I enter a value less than 10 (e.g., 7), the Estimated Budget field is still becoming visible and getting populated with 10000.

What I have already configured:

Condition: Number of Attendees ≥ 10

“Reverse if false” is enabled

“On Load” is enabled

Variable uses numeric validation (regex)

UI Policy is active and applied on Catalog Item

My doubt:

Is this issue due to data type (string vs number) in catalog variables?

Or is it because of UI Policy script executing regardless of condition?

What is the correct way to ensure the condition works properly and value is set only when attendees ≥ 10?

4 REPLIES 4

Tanushree Maiti
Mega Patron

Hi @RajeshEdaguttu ,

 

I guess your guess is correct . Its due to string field.

 

In Servienow , strings are evaluated alphabetically rather than numerically, "9" can be considered "greater" than "10".

 

SO could you check if the UI policy is

getting executed with number of attendee 9 , 8 etc. ->It should execute (Already you tested).

but failing for 11, 12 etc. -> It should not execute

 

Probable Solution:

Option 1: Deactivate String field, create a integer field with same name ( if the field is not OOB)

OR

Option 2: Use Onchange client script on that string field. User need to input numeric value in that String field

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue === '') {
      return;
   }

  var val = parseInt(newValue);
   if (val >= 10) {
      g_form.setDisplay('estimated_budget', true);  // update your field name
      g_form.setValue('estimated_budget', '10000');
   } else {
      g_form.setDisplay('estimated_budget', false);
      g_form.clearValue('estimated_budget');
   }
}

 

 

 

 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Thank you for information Tanushree,

 

Issue is still persisting even if I given input as 8,9 and also given string as input  it is showing budget. What should be potential cause for this? Any suggestion to resolve this issue??

Hi @RajeshEdaguttu ,

 

Did you try with client script.

Add a alert and after parseInt - did you check , it is showing correct value?

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

SohamTipnis
Mega Sage

Hi @RajeshEdaguttu,

 

This issue usually happens because in ServiceNow catalog variables, values are treated as strings, not numbers.

So even though you wrote the condition "Number of Attendees ≥ 10," the system might be comparing it like text instead of numbers. Because of that, the UI Policy can behave incorrectly and still make the field visible.

Also, since “On Load” is enabled, the UI Policy runs as soon as the form loads, and sometimes it applies the action before the correct value is evaluated.

👉 The best way to fix this is:
Use a UI Policy script and convert the value to a number using parseInt().

Example:

Get the value using g_form. getValue()
Convert it using parseInt
Then apply condition manually

This ensures the field becomes visible and gets value only when attendees are ≥ 10; otherwise, it stays hidden.

In short:
It’s mainly a string vs. number issue, so handling it with a small script gives you accurate results.

 

Let me know if this helps!! 😀

 


If you find my answer useful, please mark it as Helpful and Correct. ‌‌‌‌‌‌😊


Regards,
Soham Tipnis
ServiceNow Developer || Technical Consultant
LinkedIn: www.linkedin.com/in/sohamtipnis10