Does anyone have examples of transform scripts they have used to import multiple CI classes into the CMDB that they are willing to share?

jamestrezza
Giga Contributor

I have over 40 different CI classes that are in flat file format that need ongoing import to the CMDB and want to avoid having one import/transform per CI Class.

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Michael.Fry solution is probably the simplest, BUT make sure that the value for the sys_class_name is valid or you will mess things up real quick (typos will kill you).   You could add something like this to the end of Michael's script in order to validate the data before it's inserted:



var test = new GlideRecord(target.getValue("sys_class_name"));


if (!test.isValid()) {


      ignore = true;   //will skip this one row


      gs.addErrorMessage("whatever message you want to add to the logs, if any");


}



It just tries to create a new record (will not actually save it though) and then checks to see if the record is valid.


View solution in original post

10 REPLIES 10

bluefunelementa
Giga Contributor

Do you have the correct classes in the flat file? If you want to be curren then iterate through them in a script and call the IdentificationEngine-   passing the class from your flat file in the Json. Then the function will handle the rest possibly with some CI identifier assistance if not under the hardware or child classes.



https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=IdentificationEngineScopedAPI


This is great and TY for sharing.     I will have a look and see if this helps.


Hello Christian. I see the script but how do I insert a field/variable for one of the values in the name/value pairs. It does not seem to accept the variable(ex:current.short_description). Implies it wants it in JSON format but not sure if that is the case and how to do that.


thanks


I see the script but how do I insert a field/variable for one of the values in the name/value pairs. It does not seem to accept the variable(ex:current.short_description). Implies it wants it in JSON format but not sure if that is the case and how to do that.


thanks



Example:


name:'stry0900844 CI 2',


name: current.short_description,