- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 12:24 AM
Hi All,
I need to load the data from excel into glidelist field. Data in excel sheet is having multiple users(email id) with semicolon(;) and semicolon and space(; ) seperated.
I have written a transform map script. But it is not working.
Below is the piece of code used for spliting, but with no luck.
var typ= source.u_approval.toString().split(';'); //semicolon seperated
var man = typ.toString().split('; '); //semicolon and space seperated
var gr= [];
var tp = new GlideRecord('sys_user');
for(var i=0;i<man.length;i++){
tp.initialize();
...............
..............
value is not loading into glidelist field.
Please help me on this.
Thanks,
Maddy
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 02:26 AM
Hi,
Use trim function to remove the space instead of the above logic. Also declaring variable outside loop may cause problem. Your script should be like this:
var final_man= source.u_approval.toString().split(';');
var gr= [];
for(var i=0;i<final_man.length;i++){
var a = new GlideRecord('sys_user');
a.addQuery('email',final_man[i].trim());
a.query();
if (a.next()) {
gr.push(a.getValue('sys_id'));
}
}
return gr.toString();
Palani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 01:25 AM
The script you posted is incomplete and missing descriptions of the variables that are used, so I cannot really tell you where your mistake is.
In general, if you want to fill a list field, you have to set it to a string that contains a comma separated list of sys_ids, so make sure the field is set correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 02:01 AM
Hi Julian,
Below is my script.
var mag= source.u_approval.toString().split(';');
var final_man = mag.toString().split('; ');
var gr= [];
var a = new GlideRecord('sys_user');
for(var i=0;i<final_man.length;i++){
a.initialize();
a.addQuery('email',final_man[i]);
a.query();
if (a.next()) {
gr.push(a.getValue('sys_id'));
}
}
return gr.toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 02:26 AM
Hi,
Use trim function to remove the space instead of the above logic. Also declaring variable outside loop may cause problem. Your script should be like this:
var final_man= source.u_approval.toString().split(';');
var gr= [];
for(var i=0;i<final_man.length;i++){
var a = new GlideRecord('sys_user');
a.addQuery('email',final_man[i].trim());
a.query();
if (a.next()) {
gr.push(a.getValue('sys_id'));
}
}
return gr.toString();
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 04:01 AM
Hi Palani,
Thanks, It worked