Add/Remove Relationship Catalog Item raise request

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 08:28 PM
Hi,
I've a requirement to build a catalog item where end user needs to select the Action Item (Add/Remove) as per below screenshot -
1. When user selects 'Add' and 'Select the Parent CI' (It's reference to cmdb_ci table) and then user needs to select the Child CI (What will be the reference field here?)
2. When user selects 'Remove' and 'Select the Parent CI' where user selects the Parent CI, then user has has to select the Child CI (It should be reference to 'cmdb_rel_ci' and show all the available down stream relationships from only where user can select which cis needs to be removed) - How I can achieve this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 08:34 PM - edited 01-28-2025 10:19 PM
2nd variable should not refer to cmdb_rel_ci but to cmdb_ci so that they can select child CI
So you can add advanced ref qualifier on Child CI and use this so that it shows child CI only when Remove option is selected and fetched child for that parent CI
javascript: var query = ''; if(current.variables.addRemoveVariable == 'Remove') query = new CIUtils().getChildRecords(current.variables.parentCIVariable); query;
in the variable attributes add this
ref_qual_elements=parentCIVariable
In script include function query cmdb_rel_ci with that parent, bring the child cis and store in array and return that, also check if the option is remove
var CIUtils = Class.create();
CIUtils.prototype = {
initialize: function() {
},
getChildRecords: function(parentCI){
var arr = [];
var gr = new GlideRecord("cmdb_rel_ci");
gr.addQuery("parent", parentCI);
gr.query();
while (gr.next()) {
arr.push(gr.getValue('child'));
}
return 'sys_idIN'+ arr.toString();
},
type: 'CIUtils'
};
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
01-28-2025 10:14 PM - edited 01-28-2025 10:22 PM
Hi @Ankur Bawiskar ,
Thank you for your response. I've configured as below -
Select the Child CI variable -
Script Include -
I'm getting error in the script include.
Let me know if I'm doing anything wrong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 10:18 PM - edited 01-28-2025 10:21 PM
@Bijay Kumar Sha Please correct ref qualifier as shown in image.
@Ankur Bawiskar - Not sure when colon is provided it is showing html 😂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 10:19 PM
update this line as this in script include
getChildRecords: function(parentCI){
Ensure you give the correct choice value for that radio button for Remove
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