Wanting to Import data using external REST service on a schedule using Import Set / Transform Map

james_whitt
Kilo Contributor

We're running into an issue where right now we are using Scheduled Jobs to kick off a script include that uses a MID Server to connect to a 3rd party system for importing data into a ServiceNow table directly. What we want to do is use Import Sets and Transform maps also, so that we aren't pulling for 3rd part software using REST and entering data directly into the tables using the script.

With that said, we are stuck on figuring out how exactly how to "Load Data" into the import set and then kicking off then "Run Transform". We know the transform map needs to be asynchronous and that if we were using odbc, file, xml, we would go the Import Sources route, but we can't. Have to be ServiceNow scheduled import using MID server to consume the REST services.

Any help would be appreciated.

48 REPLIES 48

Hi Chris,



Good Day !!


Thank you sharing such a nice article.


However I am stuck in below step.



Create an import set


  1. Enter sys_import_set.do in text filter box
  2. Set mode to Asynchronous
  3. Keep State at Loading
  4. Set table to import set table created in step one
  5. Give description if needed


Whenever I am entering sys_import_set.do in filter box; below window is getting appeared.



Import Set.PNG



Since everything in read only, I am not able to change state as well as select Import set table.


Could you please help.



Thank you.


Rishi


Hi Rishi,



Yeah, it's been a couple of years since I wrote that. ServiceNow may have made updates to that table since the post. Looking at the dictionary entries of the fields and the ACL's it looks like that currently the sys_import_set table fields are set for read only but with the proper permissions can be written to.



So, this means there are a few things that you can do.


1) Use the Scripts-Background to simply update the data for the specific fields that need updating


2) Use a server side script to make your changes


or


3) Change the setting in the dictionary entry of the field(s) to not be read only. Then you should be able to write to the fields manually.


Thanks a lot Chris for your response !
I will follow the steps as you suggested above and get back to you if required.





Thank you.


Rishi


You can also create an import_set entry programmatically in the Scheduled job script



var impSet = new GlideRecord('sys_import_set');  


impSet.initialize();  


impSet.mode = 'asynchronous';


impSet.table_name = 'u_your_import_table';


impSet.state = 'loading';  


impSet.insert();  



This step is needed only if you need the import to be done asynchronously. You may want to monitor the import before transforming   manually(while testing) or by the system   transform later in the night. If you don't care to monitor what is imported when you are sure about the data imported and there are transform/field scripts and coalesce fields to take care of your imported data, you can insert the entries to your import table and system will automatically create import_sets for you and does the transform automatically ,immediately


is scheduled jobs under system definition or system scheduler? i see scheduled jobs under both. which one is it?