Can we map 2 list collector variables in 1 field?

ss123
Tera Contributor

I have 2 List Collector fields: Client Role 1 and Client Role 2. These 2 variables on the service portal have different options.

 

Question: Is it possible to map these 2 variables in 1 field only? Since they have different options, and needs to capture the selected value once submitted.

1:

SMSS_0-1693881031886.png

 

2: 

SMSS_1-1693881060629.png

 

1 ACCEPTED SOLUTION

S Goutham
Tera Guru

Hey @ss123 :

We cannot map multiple catalog field values back to the same field using the map-to-field option

You can have BR or Flow Designer running on these requests getting submitted and in the script section concatenate the unique values

//split used for string to array conversion
var list1 = current.variables.u_client_role.toString().split(',');
var list2 = current.variables.client_role2.toString().split(',');
var au = new ArrayUtil();
var final_list = au.union (list1,list2); // return combination all elements in both list removing duplicates
current.<your list variable> = final_list.toString();
current.update();

 

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi @ss123 

no, it's not possible to map the two mentioned variables into 1 field and you have to find another approach, for example via a Flow. The challenge is to find the right joining strategy because list collector fields are comma-separated & unordered lists of Sys ID values. ServiceNow cannot know what you have in mind when saying "joining".  For example, how do you want to handle duplicate Sys IDs?

Maik

S Goutham
Tera Guru

Hey @ss123 :

We cannot map multiple catalog field values back to the same field using the map-to-field option

You can have BR or Flow Designer running on these requests getting submitted and in the script section concatenate the unique values

//split used for string to array conversion
var list1 = current.variables.u_client_role.toString().split(',');
var list2 = current.variables.client_role2.toString().split(',');
var au = new ArrayUtil();
var final_list = au.union (list1,list2); // return combination all elements in both list removing duplicates
current.<your list variable> = final_list.toString();
current.update();

 

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue