Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Load excel file on staging table

VaidehiL
Tera Contributor

Can we upload a large Excel file directly into a staging table without converting it into JSON?

I know that ServiceNow provides the sys_import.do endpoint for this purpose, but I don't want to use a modal popup for the file upload. Is there any alternative approach to achieve this?

2 REPLIES 2

IbrarA
Kilo Sage


Hi @VaidehiL 

You can skip "sys_import.do" by using a Data Source instead. Create a record in "sys_data_source" with Type File, Format Excel, File retrieval method Attachment, and your staging table in Import set table name. Attach the Excel there and click Load All Records.

For large files you can point a Scheduled Data Import at that same Data Source. It runs in the background rather than tying up a browser session.

If you'd like users to supply the file, they can attach it to a catalog item and you move it across in script, then load it with "GlideImportSetLoader". No modal anywhere in that path.

One thing to watch, the staging table columns get generated from the file on the first load, so you can run it manually once before automating the rest.

This article has the full build with the Data Source settings and the script include: https://www.servicenow.com/community/developer-articles/import-on-demand-automate-file-imports-using...

ibrar

Ankur Bawiskar
Tera Patron

@VaidehiL 

what's your exact business requirement here?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader