- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2022 04:50 AM
Hi All,
I am filtering out the values from list collector (list_of_devices) which is referencing alm_asset table and another reference is location. So, i want to show only those assets which are from that location.
I have created a client script and a script include. I am able to return the sys_id from script include to client script but not able to set them in list collector. Below is my code:
Script include:
getSiteAssets: function() {
var arr_name = [];
var OtoO = this.getParameter('sysparm_type');
var ast = new GlideRecord('alm_asset');
ast.addQuery('location', OtoO);
ast.query();
while (ast.next()) {
arr_name.push(ast.getUniqueValue());
}
return arr_name.toString();
},
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('SiteDependentAssets');
ga.addParam('sysparm_name', 'getSiteAssets');
ga.addParam('sysparm_type', newValue);
ga.getXML(parseData);
function parseData(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
alert(answer);
g_form.setValue('list_of_devices', answer);
}
}
Please help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 02:17 AM
inform business that this is not feasible.
Either tell them
1) you will filter the list collector based on location and let user select the location to right bucket
OR
2) you will set the right bucket with the available assets for location selected and let user remove if they wish to
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
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-19-2022 05:13 AM
Hi, you dont need to iterate (via for loop ) GlideAjax response in this case.
use the below 2 line and test.
var result= response.responseXML.documentElement.getAttribute('answer');
alert("Result->"+result); // check the alert values
g_form.setValue('list_of_devices', result);
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
‎01-19-2022 05:16 AM
Hey, i tried using this but it's setting the values,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2022 05:21 AM
Is this working ? Setting the values are expected based on which column is marked as Display Value= true on that table.
Alert must be showing all sys_id of those records.
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
‎01-19-2022 05:27 AM
It's not working.
Yes, i am getting the sys_id in the alert but its not setting up in the list collector and Display value = true for display_name, so i am returning display name from script include and still not setting the values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2022 05:33 AM
return the display name will not work for List Collector because List Collector need sys_id of record from that table only.
try with this .. use getUniqueValue() for sys_id and return the arr object.
getSiteAssets: function() {
var arr = [];
var OtoO = this.getParameter('sysparm_type');
var ast = new GlideRecord('alm_asset');
ast.addQuery('location', OtoO);
ast.query();
while (ast.next()) {
arr.push(ast.getUniqueValue());
}
return arr.join()
},
Thanks,
Ashish
Please mark correct answer and helpful for others if it works for you
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution