import list with list view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 06:47 AM - edited 04-16-2025 06:50 AM
Hi,
I have created a transform map and i have a site poc field which is list collector field reference to user in my target but a string in my source with email values separated by comma. Now when importing the data i want it to be mapped correctly. I have created a field mapping script but that is not working
answer = (function transformEntry(source) {
var grp_type = '';
var result = [];
var inputArray = source.u_site_poc.split(',');
var gtype = new ArrayUtil().unique(inputArray);
for (var i = 0; i < gtype.length; i++) {
var grpType = new GlideRecord('sys_user');
grpType.addQuery('email', gtype[i]);
grpType.query();
if (grpType.next()) {
grp_type = grpType.sys_id.toString() + ',';
}
}
return usr.sys_id;
})(source);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 06:59 AM - edited 04-16-2025 07:01 AM
Hello @MaharshiC ,
Your function is trying to return a property of some "usr" object, which is not defined.
Please use the following script instead:
answer = (function transformEntry(source) {
var result = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('email', 'IN', source.u_site_poc);
gr.query();
while (gr.next()) {
result.push(gr.getUniqueValue());
}
return result.toString();
})(source);
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 07:20 AM - edited 04-16-2025 07:23 AM
Hi @Robert H ,
Will this work as my source is a string field separated by commas?It is just taking the first value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 08:15 AM - edited 04-16-2025 08:23 AM
Hello @MaharshiC ,
Yes, the "IN" operator in addQuery() works with comma separated strings.
Input file:
Target record after transformation:
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2025 09:04 AM
Hi @Robert H ,
I tried the below code but still inserting just a single value but i can see in my staging string field both the values are there but it is not getting copied in my target list field
answer = (function transformEntry(source) {
var result = [];
var gr = new GlideRecord('sys_user');
gr.addQuery('email', 'IN', source.u_site_poc);
gr.query();
while (gr.next()) {
result.push(gr.getUniqueValue());
}
return result.toString();
})(source);