- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:26 PM
We have a requirement to display all devices per a parent site in a list collector. When I call the script include, I can see in the system logs that the strQry value is being populated but shows 'no matches found' in the list collector field on the form (screenshot below). Or maybe there is there a way to add that to the query "u_current_fw_versionISNOTEMPTY^u_current_fw_versionNSAMEASu_target_firmware_version^u_active_policy_exceptionISEMPTY" that is needed and not use a script include but I don't know how to add the filter for the parent site as well. I am not sure what I am missing here and would very much appreciate any help here.
Here is my list collector:
The script include is below:
return strFSAssets;
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 02:43 PM
Hi Colleen,
You are suppose to return sys_id to the reference qualifier. Could you please fix the script accordingly?
function ListFieldSiteAssets() {
//var ListFieldSiteAssets = Class.create();
var strParentSite = current.variables.parent_site; //user chosen in variable
gs.log("parent site " + current.variables.parent_site + " var " + strParentSite );
if (strParentSite!= '') {
//if not empty
strQry = '^sys_idIN' + _getFSAssetsIds(strParentSite); //get the list of models at the parent site
gs.log("strQry " + strQry );
}
return strQry; //return the query
}
function _getFSAssetsIds(parent) {
var strFSAssets = '';
// Get all Field site assets
gs.log( " parent in function " + parent );
var grFSA = new GlideRecord('u_field_site_assets');
grFSA.addQuery('u_connected_device', parent); // u_connected_device is the name for the parent site on the table
grFSA.addEncodedQuery('u_current_fw_versionISNOTEMPTY^u_current_fw_versionNSAMEASu_target_firmware_version^u_active_policy_exceptionISEMPTY');
grFSA.query();
while(grFSA.next()){
if (strFSAssets.length > 0) {
// build a comma separated string of groups if there is more than one
strFSAssets += ',' + grFSA.sys_id;
} else {
strFSAssets = '' + grFSA.sys_id;
}
}
return strFSAssets;
}
// type: 'ListFieldSiteAssets'
//};
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 02:25 PM
Hi @Colleen1 ,
As per standard practice, I don't see any function call from List Collector , even you are calling the script include name itself and there is no any function/method defined in script include for calling from outside , you create a inline function [ _getFSAssetsIds ] for internal check.
review any existing script include in your system and create a function for call and update the List Collector ref qual
like this
javascript: new ListFieldSiteAssets().<methodName()>
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 02:43 PM
Hi Colleen,
You are suppose to return sys_id to the reference qualifier. Could you please fix the script accordingly?
function ListFieldSiteAssets() {
//var ListFieldSiteAssets = Class.create();
var strParentSite = current.variables.parent_site; //user chosen in variable
gs.log("parent site " + current.variables.parent_site + " var " + strParentSite );
if (strParentSite!= '') {
//if not empty
strQry = '^sys_idIN' + _getFSAssetsIds(strParentSite); //get the list of models at the parent site
gs.log("strQry " + strQry );
}
return strQry; //return the query
}
function _getFSAssetsIds(parent) {
var strFSAssets = '';
// Get all Field site assets
gs.log( " parent in function " + parent );
var grFSA = new GlideRecord('u_field_site_assets');
grFSA.addQuery('u_connected_device', parent); // u_connected_device is the name for the parent site on the table
grFSA.addEncodedQuery('u_current_fw_versionISNOTEMPTY^u_current_fw_versionNSAMEASu_target_firmware_version^u_active_policy_exceptionISEMPTY');
grFSA.query();
while(grFSA.next()){
if (strFSAssets.length > 0) {
// build a comma separated string of groups if there is more than one
strFSAssets += ',' + grFSA.sys_id;
} else {
strFSAssets = '' + grFSA.sys_id;
}
}
return strFSAssets;
}
// type: 'ListFieldSiteAssets'
//};
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2023 12:33 PM
This worked perfectly!!! Thank you !!!