Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Importing an Excel file into a list type field

Kurumi
Tera Contributor

I want to import comma separated data into a list type field.
↓data to import

Kurumi_0-1690863938815.png

↓field to import to

Kurumi_3-1690864251407.png

 

Kurumi_2-1690864212298.png

However, when I import it, the yellow line text is displayed.

Kurumi_4-1690864498532.png

 

When I execute the import, the value is not imported to the target column ("sample list").

Kurumi_5-1690864829314.png

I also checked the import set table, but although the target column ("sample list") has been added, the value has not been obtained.

Kurumi_6-1690864866285.png

The target column is not added to the field map of the created transform map.

Kurumi_7-1690864900497.png

Here is the community post for reference.

https://www.servicenow.com/community/developer-forum/importing-data-into-a-list-type-field/m-p/16324...

 

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.

4 REPLIES 4

Sagar Pagar
Tera Patron

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

The world works with ServiceNow

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?

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

The world works with ServiceNow

Nayan  Dhamane
Kilo Sage

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.

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.