How to push multiple value in Variable

Not applicable

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

PallaviShinde2_1-1717051952257.png

Regards,

Pallavi 

 

 

4 REPLIES 4

Voona Rohila
Tera Patron

HI @Community Alums 

 

Can you show the gliderecord part of the above code?

Not applicable

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 

SarthakKashyap_0-1717052698883.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

dgarad
Tera Sage

Hi @Community Alums 

 change the return code

 

return access.join(',')

 

  

Hayo Lubbers
Kilo Sage

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.