import data fix script

kevin_cunningha
Kilo Contributor

I am looking for some resources to write a fix script that imports data and runs the corresponding transform map associated with the table. I have found resources about fix scripts and importing data but not of the two together.

1 ACCEPTED SOLUTION

Hello Kevin,



Thanks for the update. You can create one scheduled import set and for the additional import set(populate the parent field, set run as "After parent runs" and parent field to the first scheduled import set). This will ensure all additional import set will be executed as soon as parent scheduled import set is executed.



P.S: Do not schedule multiple imports at the same time. Running multiple imports concurrently may negatively impact performance or cause an instance outage.


View solution in original post

13 REPLIES 13

Hello Kevin,



Thanks for the update. As soon as the data is loaded, transformation map will kick automatically. Please let me know if you have any questions.


So I am at the point Pradeep where I have multiple import sets thanks to what you said earlier. Now that I have my import sets and transform maps I want to write a script so that I can come back and transform the data again. The idea is that I imported the data and transformed it all and someone is going to use this data. When they are done with it, I will delete anything they did with the data and re-transform the imported data for the next person to use. I don't want to have to delete the data and run each transform map by clicking on them individually. Can I write a script to run all the transform maps from the data that was imported?


Can you please give more info on this : I will delete anything they did with the data and re-transform the imported data for the next person to use :


You mean you will delete and import the new data and transform?



BTW, There is a scheduled job that runs every day at midnight. By default, it will query all import sets that are older than 7 days and delete the import set and all related tables, eg. the import set table records. If this scheduled job is not active in your instance, we recommend that you activate it as soon as possible to mitigate the growing import set tables that you may have, especially if they are recurring imports.


Sorry if I was not clear Pradeep. I am working on an application that has test data for people to use to understand the application's functionality. The people who are using the test data will be able to go in and add more data or edit the data current in the app. I have written a fix script to delete all the data inside the application that is part of the test data. I have developed import sets to for all the data that is needed and have developed transform maps for each import set as well. I want to delete all the test data and then run a script that will run all the transform maps on the imported data so that the app has the same original test data for someone to use. I want to be able to use the imported data over and over again and don't want to have to run each individual transform map one at a time. I would like to write a script to run all the transform maps at once. I found a reference to the following resource. Run transform in server side script and I see that you commented on this article as well. Would the GlideImportSetTransformerWorker() method be applicable for me?


Hello Kevin,



No worries. The req is clear now. I think GlideImportSetTransformerWorker should work in your case. However as I mentioned all the import set records older than 7 days will be deleted.


So in your case, you will have to write a scheduled job(so that it can trigger as per defined interval) and via script re-import the records in the target table.


http://wiki.servicenow.com/index.php?title=Creating_a_Scheduled_Job