How to Populate List collector values to the Multi line text variable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 07:06 AM
Hello Team,
I need your help. I’m trying to copy the value from a list collector to a multiline text variable, I attempted with the client script and script include but it's not working.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
// Get the list collector values (comma-separated sys_ids)
var listCollectorValues = g_form.getValue('ad_group_members'); // Change this ID
if (listCollectorValues) {
var ga = new GlideAjax('SPR_Repo'); // Call Script Include
ga.addParam('sysparm_name', 'getNames');
ga.addParam('sysparm_ids', listCollectorValues);
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('list_collectors_names', response); // Change this ID
}
});
}
}
getNames: function() {
var userIds = this.getParameter("sysparm_ids");
gs.log('User IDs:', userIds); // Debug statement
if (!userIds) return '';
var userNames = [];
var idsArray = userIds.split(',');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', 'IN', idsArray);
gr.query();
while (gr.next()) {
userNames.push(gr.getValue('name')); // Get full name
}
gs.log('User Names:', userNames); // Debug statement
return userNames.join('\n'); // Join with line breaks
},
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 05:29 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader