Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Issue with Catalog UI Policy condition and numeric input handling

RajeshEdaguttu
Kilo Explorer

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?

1 REPLY 1

Tanushree Maiti
Kilo 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: