Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2025 06:13 PM
HI all ,
For the single user it is goving correct answer but for the multiple users it is giving undefined answer
Can anyone correct this script :
source.u_owner_name:- multiple user id is coming ,
return: undefined output is coming
// Transform Map Script (Single reference field: return the first matched user sys_id)
answer = (function transformEntry(source) {
var owners = source.u_owner_name;
var userIds = [];
var arr = owners.split(',');
gs.log('TM Owners tokens=' + arr.length);
for (var i = 0; i < arr.length; i++) {
var userVal = (arr[i] || '').trim();
if (!userVal) continue;
var userGR = new GlideRecord('sys_user');
userGR.addQuery('user_name', userVal);
userGR.query();
while (userGR.next()) {
userIds.push(userGR.name);
gs.log('test_123'+userIds);
return userIds.join(',') ;
}
}
})(source);
Solved! Go to Solution.