You are currently viewing ServiceNow CMDB Identification Rule Demo

ServiceNow CMDB Identification Rule Demo

Welcome to this post.

Here we go through the step by step execution & discussion of ServiceNow CMDB Identification Rule or IRE rules.

To make this successful we will do the following:-

  • add a identification rule using CI Class Manager to A10 Load Balancer Partition [cmdb_ci_lb_a10_partition] table.
  • Then we try to import data into A10 Load Balancer Partition table using import set
  • Here the dat source will be an excel sheet
  • We direct the system to use IRE rules before transforming data into table using Transform script.
  • I will show logs of data transformation to show the use of IRE rules

Video Tutorial

Please watch this complete video and get the necessary scripts etc from this article.

Add Identification Rule to A10 Load Balancer Partition table

  • Go to CI Class Manager and click on hierarchy on top left
  • Find table A10 Load Balancer Partition and click on it
  • Now from left navigate to Identification Rule tab
  • Under Identifier entries click on plus(+) sign and add name as identifier, priority as 100
  • Click Save

Data Source & Transform Map To Upload Data

  • By using generic load data process we have created an import set table & transform map matching A10 Load Balancer Partition table
  • Data Source is as follow:-
  • Transform Map is as follows:-

On Before Transform Script:-

Below script activate IRE engine before data imports and produce logs for more understanding.

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
	
	// Add your code here
	var cmdbUtil = new CMDBTransformUtil();
	cmdbUtil.setDataSource('ImportSet');
	cmdbUtil.identifyAndReconcile(source, map, log);
	ignore = true;
	
	if (cmdbUtil.hasError()) {
		var errorMessage = cmdbUtil.getError();
		log.error("SNOW911" + errorMessage);
		log.error("SNOW911 ERROR_CI: " + source.u_name); 
        this.operation_importset = "error";
        } else {
            target.sys_id = cmdbUtil.getOutputRecordSysId();
            gs.info('SNOW911 IE Output Payload: ' + cmdbUtil.getOutputPayload());
            var parser = new JSONParser();
            var parsed = parser.parse(cmdbUtil.getOutputPayload());
            var operation = parsed.items[0].operation;
            if (operation == "INSERT") {
                gs.info("SNOW911 CREATED_CI " + source.u_name + ": " + cmdbUtil.getOutputRecordSysId());
                //target.u_ci_notes = source.u_ci_notes;
				this.operation_importset = "inserted";
				
            }
            if (operation.indexOf("UPDATE") > -1) {
                gs.info("SNOW911 UPDATED_CI " + source.u_name + ": " + cmdbUtil.getOutputRecordSysId());
				this.operation_importset = "updated";
            }
            if (operation.indexOf("NO_CHANGE") > -1) {
                gs.info("SNOW911 NO_CHANGE_CI " + source.u_name + ": " + cmdbUtil.getOutputRecordSysId());
				
            }
        }
	
})(source, map, log, target);
end footer

Leave a Reply