- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 12:35 PM
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.
Solved! Go to Solution.
- Labels:
-
Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 07:05 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 06:01 PM
On your Transform Map, make sure your Target table is cmdb_ci. Then check Run Script and you can use something like below. You need to have a field that can be used for mapping the class. We use assettype. We also set other data, but gives you the idea.
if (source.u_assettype == 1) { | |
target.sys_class_name = "cmdb_ci_ip_network"; | |
target.category = 'Enterprise Hardware'; | |
target.subcategory = 'other'; | |
target.install_status = 1; |
}
else if (source.u_assettype == 2) {
target.sys_class_name = "cmdb_ci_ip_firewall"; | |
target.category = 'Enterprise Hardware'; | |
target.subcategory = 'firewall'; | |
target.install_status = 1; |
}
else if (source.u_assettype == 3) {
target.sys_class_name = "cmdb_ci_nas_file_system"; | |
target.category = 'Enterprise Hardware'; | |
target.subcategory = 'tape/disk devices'; | |
target.install_status = 1; |
}
else if (source.u_assettype == 4) {
target.sys_class_name = "cmdb_ci_ip_router"; | |
target.category = 'Enterprise Hardware'; | |
target.subcategory = 'router'; | |
target.install_status = 1; |
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2017 07:05 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2017 06:50 AM
What do I do if my imported file has the display value for the Class rather than the actual value?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2017 06:54 AM
Then your source would be Class, for example:
if (source.class == Windows) {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2017 06:59 AM
Sorry I should have been more clear, I don't want to have to build out IF statements for every potential Class - I'd like to have the Class I'm given resolve correctly on its own. I didn't think the data I have would work without some scripting help...