Importing an Excel file into a list type field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 09:47 PM
I want to import comma separated data into a list type field.
↓data to import
↓field to import to
However, when I import it, the yellow line text is displayed.
When I execute the import, the value is not imported to the target column ("sample list").
I also checked the import set table, but although the target column ("sample list") has been added, the value has not been obtained.
The target column is not added to the field map of the created transform map.
Here is the community post for reference.
Currently, we are considering adding a Transform Script to the Transform Map and setting a script that adds a value to the list for each comma (",").
If so, what kind of script should I add?
Also, if you know any other method, please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 10:14 PM
Hi @Kurumi,
Take a look at this KB. It will help you to import data to list type field using Excel templates.
How to Import List Type field by using Excel or CSV file
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 10:33 PM
Hello @Sagar Pagar
thank you for your reply.
By changing the system property that was in the KB,
I was able to import.
However, I would like to import without changing system properties as much as possible. Will it be difficult to achieve?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 10:39 PM
Hi @Kurumi,
Yes. If you keep glide_list field type in system property. It will ignore the list type fields via template inmport.
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 10:39 PM
Hello @Kurumi,
Firstly if in import set please create the sample list field as a string fields so we have all the data in our import set table.
Please create a new field mapping and select source script as an option and use the below script:
var list = source.source_filed;
var arr = list.split(',');
var str = [];
for(var i = 0; i < arr.length; i++){
var gr = new GlideRecord('sys_user');
gr.addQuery('name', arr[i]);
gr.query();
if(gr.next()){
str.push(gr.sys_id);
}
}
return str.toString();
This is tried and tested.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.