How to hide the checkbox variables in Ritm when they are unchecked and show only checked variables

Karthik Reddy11
Tera Contributor

How to hide the checkbox variables in Ritm when they are unchecked and show only checked variables

 

find_real_file.png

It is showing all variables 

can i know which catalog client script i should use

1 ACCEPTED SOLUTION

@Karthik Reddy 

Okay then in that case first revert the changes which I suggested above and make your Line number 10 look like below:

 <div ng-if="variable.type !='7' || (variable.type =='7' && variable.display_value!='false')">

Now for your new requirement, update line number 25 as below:

 <span ng-if="variable.type !='7'" ng-switch-default class="pre-wrap">{{::variable.display_value}}</span>

This is working as you need.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

21 REPLIES 21

Sagar Agarwal
Mega Guru

Hi Karthik,

 

You can create a UI policy and check "Applies to Request Items".

For the condition, you can add all the checkboxes you want to hide with OR

Like > Desktop is false OR laptop is false OR ...

and create the UI policy action for each of the checkboxes to set visible false

Like > Desktop | visible | false

 

 

If my answer helped you in any way, please then mark it as helpful.

Kind regards,

Sagar

Karthik Reddy11
Tera Contributor

Hi sagar i have written the catalog client script its working but when i checked in Service portal it is not working showing all check boxes whether it is true/false

find_real_file.png

script:

function onLoad() {
//Type appropriate comment here, and begin script below
var a = g_form.getValue('desk_monitor_external_monitor');
if (a == 'true')
g_form.setDisplay('desk_monitor_external_monitor', true);
else {
g_form.setDisplay('desk_monitor_external_monitor', false);
}
var b = g_form.getValue('docking_station');
if (b == 'true')
g_form.setDisplay('docking_station', true);
else {
g_form.setDisplay('docking_station', false);
}
var c = g_form.getValue('external_cd_dvd_drive_laptop');
if (c == 'true')
g_form.setDisplay('external_cd_dvd_drive_laptop', true);
else {
g_form.setDisplay('external_cd_dvd_drive_laptop', false);
}
var d = g_form.getValue('keyboard');
if (d == 'true')
g_form.setDisplay('keyboard', true);
else {
g_form.setDisplay('keyboard', false);
}
var e = g_form.getValue('audio_headset');
if (e == 'true')
g_form.setDisplay('audio_headset', true);
else {
g_form.setDisplay('audio_headset', false);
}
var f = g_form.getValue('laptop_backpack');
if (f == 'true')
g_form.setDisplay('laptop_backpack', true);
else {
g_form.setDisplay('laptop_backpack', false);
}
var g = g_form.getValue('laptop_battery');
if (g == 'true')
g_form.setDisplay('laptop_battery', true);
else {
g_form.setDisplay('laptop_battery', false);
}
var h = g_form.getValue('mouse');
if (h == 'true')
g_form.setDisplay('mouse', true);
else {
g_form.setDisplay('mouse', false);
}
var i = g_form.getValue('usb_memory_stick');
if (i == 'true')
g_form.setDisplay('usb_memory_stick', true);
else {
g_form.setDisplay('usb_memory_stick', false);
}
var j = g_form.getValue('kensington_lock_docking_station');
if (j == 'true')
g_form.setDisplay('kensington_lock_docking_station', true);
else {
g_form.setDisplay('kensington_lock_docking_station', false);
}
var k = g_form.getValue('bew_token');
if (k == 'true')
g_form.setDisplay('bew_token', true);
else {
g_form.setDisplay('bew_token', false);
}
var l = g_form.getValue('car_charger');
if (l == 'true')
g_form.setDisplay('car_charger', true);
else {
g_form.setDisplay('car_charger', false);
}
var m = g_form.getValue('desktop');
if (m == 'true')
g_form.setDisplay('desktop', true);
else {
g_form.setDisplay('desktop', false);
}
var n = g_form.getValue('laptop');
if (n == 'true')
g_form.setDisplay('laptop', true);
else {
g_form.setDisplay('laptop', false);
}
var o = g_form.getValue('ip_desk_phone');
if (o == 'true')
g_form.setDisplay('ip_desk_phone', true);
else {
g_form.setDisplay('ip_desk_phone', false);
}
var p = g_form.getValue('mobile_phone');
if (p == 'true')
g_form.setDisplay('mobile_phone', true);
else {
g_form.setDisplay('mobile_phone', false);
}
var q = g_form.getValue('pda_handheld');
if (q == 'true')
g_form.setDisplay('pda_handheld', true);
else {
g_form.setDisplay('pda_handheld', false);
}
var r = g_form.getValue('speaker');
if (r == 'true')
g_form.setDisplay('speaker', true);
else {
g_form.setDisplay('speaker', false);
}
var s = g_form.getValue('others');
if (s == 'true')
g_form.setDisplay('others', true);
else {
g_form.setDisplay('others', false);
}

}

Hi,

Can you check run script ui type as seelcted 'All'.I hope you selected as only 'Desktop'.

Please mark as correct answer if it helped

R,

Suresh.

Regards,
Suresh.

shloke04
Kilo Patron

Hi @Karthik Reddy 

What other have said, you can use a Catalog UI Policy or a Catalog or client script to hide the unchecked checkboxes in Native view and it will work which you have already done.

But this will not hide it from ticket page on Service Portal which is an expected behavior and there is a known problem ticket for the same as well. Please refer the details below:

This is expected behaviour. The widgets on the default "ticket" page (ticket-conversation and ticket-fields) do not include or contain a Form widget, so they can not use Client Scripts or UI Policies. They are simpler widgets to only show information without benefit of those conditional scripts.
 
As a workaround, to be able to add UI Policies or Client Scripts, use or create another page that makes use of the Form widget. Then UI Policies and Client Scripts will be available.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0683191

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

@Karthik Reddy 

Did you review the suggestion below by me. If you have a follow up query then do let me know else please mark the answer as correct and close this thread for others.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke