- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 07:47 AM
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,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 01:58 AM
@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
2.
3. OUTPUTS-:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 07:58 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 08:15 PM
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
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 08:27 PM
Hello @kishorchika
You can configure the Ui policies as shown in the screenshot
Condition:
Ui policy action:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 02:19 AM
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