Load multiple users into target field of type 'List' using data source

Mounika1001
Tera Contributor

delegate tabel.png

Field map.png

 hello, 

    I want to load multiple users on target table field 'Travelers list' which is 'List' field type. Travelers list takes users from reference table 'sys_user' search with user_name(id) column.

Currently created this field map and it is just updating one user. But when I load excel with multiple userid's seperated by comma all users must be saved in target table field. 

please help me with the script.

Eg: A098765,A075431,A723090 (userid's) in excel of source table column

2 ACCEPTED SOLUTIONS

Complete script to copy in script field:

 

answer = (function transformEntry(source) {

    var users = [];
    var grUser = new GlideRecord("sys_user");
    grUser.addEncodedQuery("user_nameIN" + source.u_traveler_userid);
    grUser.query();
    while (grUser.next()) {
        users.push(grUser.getValue("sys_id") + "");
    }
    return users.join(",");

})(source);
If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

Hello @Mounika1001 

 

The script should work irrespective of the number of users in the field. Please check once the length of your source (import set table) field length and also target field length.

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

6 REPLIES 6

Hello @Mounika1001 

 

The script should work irrespective of the number of users in the field. Please check once the length of your source (import set table) field length and also target field length.

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

Thank you @Ahmmed Ali. It works fine

Regards

Mounika