How to push multiple value in Variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2024 11:53 PM
I have one variable having type "List collector" with list table sys_user_group, right now i am able to push single value in variable, but i want to push multiple in the variable. The issue is when I select 2 values from catalog item it is taking single value only. Please suggest me below is script i am using to push the values
Regards,
Pallavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 12:04 AM
HI @Community Alums
Can you show the gliderecord part of the above code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 12:05 AM
Hi @Community Alums ,
I tried your code in my PDI and it works for me. Please refer below script
var incgr = new GlideRecord('incident');
incgr.addQuery('sys_id', '47064b68a9fe19810186793eefffc9b7');
incgr.query();
if(incgr.next()){
var user = [];
var userGr = new GlideRecord('sys_user');
userGr.addEncodedQuery('nameSTARTSWITHuser');
userGr.query();
while(userGr.next()){
user.push(userGr.sys_id.toString());
}
gs.print("User = " + user.join(","));
incgr.watch_list = user.join(",");
incgr.update();
}
Result
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 12:11 AM - edited ‎05-30-2024 12:13 AM
Hi @Community Alums
change the return code
return access.join(',')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2024 12:12 AM
Hi @Community Alums ,
You join with a \n instead of a comma. List Collectors have a comma seperated list of values.
You can use the toString() method or keep the join() without parameters.