logo

NJP

Scheduled Import From Google Sheets

Import · Apr 09, 2022 · article

Let’s see how to import data automatically with scheduled imports,

First open your google sheet and go to File -> Share -> Publish to Web

image

Now select sheet which contains data in my example it’s sheet1 and select comma separated values (.csv) in next checkbox.

image

Now copy link from below box, which looks like docs.google.com

Now open your instance Filter Navigator-> Administration -> Data sources

image

Click new

Now select file retrieval method as HTTPS and then right click file path and go to config dictionary and change max length to 200, as Google sheet published URL is more than 100 characters,

image

if you skip this step, you will face errors.

image

Now Go back to data source form and complete fields as below

image

Notes: Do not use http or https before server name, it should be only docs.google.com and remaining url (after /spreadsheet ), put in file path, Now click load test 20 records, If records are fetched successfully, then go to next step, else check what you missed in above steps,

Now Lets create transform map for this, scroll down and click on new in transform map

image

Now create transform map as per your requirements

image

Here in my case, I am generating email ids for my users automatically, if you want any script to be written, please write it.

After this click auto-mapping assist, it will map some fields,

image

you can map remaining fields as per your requirements, Do not forgot to create coalesce field, else it will keep creating new records after the data is imported.

Now this part is completed Now visit scheduled imports

image

& Click on new select data source and make schedule as per your requirements, in this case for testing purpose I am running it periodically after 5 minutes.

image

Now save this record & done.

From now any changes made in the sheets will we auto inserted/updated in our tables after the specified time, please make sure if you add new column in Google sheet, please map it in transform map again, or if removed then remove from transform map also.

Now let’s check

Data in Google Sheet

image

User’s table when data imported

image

Regards,

Kaustubh Kulkarni

If you found this article useful, please mark this helpful.

View original source

https://www.servicenow.com/community/developer-articles/scheduled-import-from-google-sheets/ta-p/2322099