- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 02:44 AM
Hi all,
We've been asked to show a field and hide another field if a certain cmdb_ci class has been chosen when raising a change.
In this case the class the sys_cmdb_netgear.
Normally we'd do a ui action for this but it needs to happen when the config item has been chosen as the change is requested when pressing submit.
I'm trying to query the class when the config items is selected but doesn't work.
below is the script i'm trying to work with:
=========
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 05:51 AM
@Sam Motley Could you try with the following code.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ci = g_form.getReference('cmdb_ci', getCIDetail);
function getCIDetail(ci) {
if (ci.sys_class_name == 'cmdb_ci_netgear') {
g_form.setDisplay('u_network_device', true);
g_form.setDisplay('u_configuration_items', false);
alert("class is true");
} else {
g_form.setDisplay('u_network_device', false);
g_form.setDisplay('u_configuration_items', true);
alert("class is false");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 07:29 AM
thanks @Sandeep Rajput that's worked, looks like i wasn't far off!
much appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 02:55 AM
Hi @Sam Motley,
You have to check/compare the class name.
Try this updated scripts:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.cmdb_ci.sys_class_name == 'cmdb_ci_netgear') {
g_form.setDisplay('u_network_device', true);
g_form.setDisplay('u_configuration_items', false);
alert("class is true");
} else {
g_form.setDisplay('u_network_device', false);
g_form.setDisplay('u_configuration_items', true);
alert("class is false");
}
}
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 04:54 AM
Thanks for checking out my issue @Sagar Pagar however this didn't work 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 04:57 AM
Hi @Sam Motley,
Can you try by replacing line as:
if (g_form.getTableName() == 'cmdb_ci_netgear') {
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 05:08 AM
hi @Sagar Pagar thanks for the suggestion but still not working