Catalog UI Policy not working on CITEM

kishorchika
Mega Contributor

Hello Everyone,

I need your help please, 

I would like to apply catalog UI POLICES with two variables ( select box).

When to apply:

If      var 1 is X

and  var 2 is X

OR

if     var 1 is Y 

 and var 2 is X

The UI policy  action:

The var 3 ( select box) should be visible.

This UI policy works only when I put one condition = var 1 is X, when I add the seconde one ( var 2 is X) it stops working.

Thank you in advance, 

 
1 ACCEPTED SOLUTION

pranita-24
Giga Guru

@kishorchika 

Hi as per your requirement I have created one catalog UI policy.
There are three select box variables.
1. Class---> Options A]First year  B] Second Year
2. Division---->A] A B] B
3. Department---->A]Computer B] Electrical
Conditions-:
When Class is First year  and Division is A OR Class is Second year and Division is A 
Then Variable Department should be visible .
Below are some Screenshots.
INPUTS-:
1

pranita24_0-1735638395563.png

 

 

2.

pranita24_1-1735638395018.png

 

3. OUTPUTS-:

pranita24_2-1735638395454.png

 

 

pranita24_3-1735638395598.png

 

pranita24_4-1735638395105.png

 

pranita24_5-1735638396049.png

 

pranita24_6-1735638395424.png

 

 

You can try this I am sure it will help you to fulfill your requirement. 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Pranita

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@kishorchika 

for this it's better to have 2 onChange catalog client scripts

something like this

Script 1: For var 1

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

  var var1 = g_form.getValue('var1');
  var var2 = g_form.getValue('var2');

  if ((var1 === 'X' && var2 === 'X') || (var1 === 'Y' && var2 === 'X')) {
    g_form.setVisible('var3', true);
  } else {
    g_form.setVisible('var3', false);
  }
}

Script 2: For var 2

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

  var var1 = g_form.getValue('var1');
  var var2 = g_form.getValue('var2');

  if ((var1 === 'X' && var2 === 'X') || (var1 === 'Y' && var2 === 'X')) {
    g_form.setVisible('var3', true);
  } else {
    g_form.setVisible('var3', false);
  }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Runjay Patel
Giga Sage

Hi @kishorchika ,

 

You can use client script and use below script.

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

    // Get the values of the variables
    var var1 = g_form.getValue('var1'); // Replace 'var1' with the actual name of your first variable
    var var2 = g_form.getValue('var2'); // Replace 'var2' with the actual name of your second variable

    // Check the conditions
    if ((var1 == 'X' && var2 == 'X') || (var1 == 'Y' && var2 == 'X')) {
        // Make var3 visible
        g_form.setDisplay('var3', true); // Replace 'var3' with the actual name of your third variable
    } else {
        // Hide var3
        g_form.setDisplay('var3', false);
    }
}

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Juhi Poddar
Kilo Patron

Hello @kishorchika 

You can configure the Ui policies as shown in the screenshot

Condition:

JuhiPoddar_0-1735619028727.png

Ui policy action:

JuhiPoddar_1-1735619119267.png

This is tested in my PDI and it works as expected.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

Hello @kishorchika 

Thank you for marking my response as helpful.

As per new community guidelines, you can mark multiple answer as an accepted solution.

If my response helped, kindly mark it as an accepted solution as well. It helps future readers to locate the solution easily in community.

 

Thank You

Juhi Poddar