Populate list of child values from relationship table filtering condition in name of catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 11:58 PM
Hi,
I want to Populate list of child values from relationship (cmdb_rel_ci) table filtering condition ()in "vm name" variable of catalog item, which is reference field refers to "cmdb_ci_vmware_instance" table(this is referring to the instance table because I want to filter all the vm name which has relationship where type is "Provides storage for::Stored on " and Parent does not contains Placeholder).
I have tried using Script include and called the same in "vm name" variable's reference qual as "javascript:getvm()".
this is not working looking for help.
Script include:
var getVM = Class.create();
getVM.prototype = {
initialize: function() {},
getVM: function() {
gs.log("In function");
var option = [];
var nameArray = [];
var flag = new GlideRecord('cmdb_rel_ci');
flag.addEncodedQuery('parentNOT LIKEPLACEHOLDER^type!=c6fd799338a02000c18673032c71b81d');
flag.query();
while (flag.next()) {
option.push(flag.getDisplayValue('child'));
}
gs.log("childArrya"+ option);
var vmwareResponse = new GlideRecord('cmdb_ci_vmware_instance');
vmwareResponse.addQuery('name', 'IN', option);
vmwareResponse.query();
while (vmwareResponse.next()) {
nameArray.push(vmwareResponse.name.toString());
}
return nameArray;
},
type: 'getVM'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 06:02 AM - edited 08-14-2024 06:06 AM
Hi @DhanashriP ,
if you returning the name in reference qualifier you need to update like as below
javascript:'nameIN'+new getVM().getVM()
if you returning sys_id in reference qualifier you need to update like as below
javascript:'sys_idIN'+new getVM().getVM()
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK