IRE and Web Service

Gaetano De Mitr
ServiceNow Employee
ServiceNow Employee

Hello everyone,

The IRE works Only with a set of data source? 

I'm using a Inbound Web Service to create or update CI into CMDB, and I set discovery_source field with "WS" value.

Do I use IRE API into scripted rest api?

Otherwise,

Do I implement all Logic to create or update CI on CMDB without using Identificativo Rule?

I guess that even the Reconciliation rule Will not work with the Web Service.

Right?

26 REPLIES 26

DaveHertel
Kilo Sage
Kilo Sage

Hi -- While I'm not sure about invoking IRE via web service (haven't done that...),  the new & free online CMDB course recently published by ServiceNow training covers how to invoke the IRE from an inbound import.  Perhaps this will help as your explore similar capabilities via inbound services.

Free, online CMDB Fundamentals course here:

 https://nowlearning.service-now.com/lxp?id=overview&sys_id=c120bb5bdbd0c8103e3aaca2ca9619bf&type=pat...

In particular, for your question - see the section about Populating the CMDB discusses imports and invoking the IRE via script during transform

find_real_file.png

 

Hope this helps some?   Please post reply if you get this invoked via web service - it'd be good to know...

 

Hi Dave,

thanks for answer:

 

I create an Import Set table (with releated REST api to create record on the table),

I attached a Transform map to the Import Set with "On Before" scripted:

(function runTransformScript(source, map, log, target) {
// Call CMDB API to do Identification and Reconciliation of current row
var cmdbUtil = new CMDBTransformUtil();
cmdbUtil.setDataSource('MySource1'); //This is the name you added in the step above. 
cmdbUtil.identifyAndReconcile(source, map, log);
ignore = true;

if (cmdbUtil.hasError()) {
        var errorMessage = cmdbUtil.getError();
        log.error(errorMessage);
} else {
        log.info('IE Output Payload: ' + cmdbUtil.getOutputPayload());
        log.info('Imported CI: ' + cmdbUtil.getOutputRecordSysId());
}

})(source, map, log, target);

 

When the Import Set WS is called the record on CMDB is created or updated following the current Identification and Reconciliation rule configurated on the ServiceNow instance, but the WS answer me with the same response:

{
    "import_set": "ISET0010004",
    "staging_table": "u_cmdb_ci_mysource1_staging",
    "result": [
        {
            "transform_map": "TransformMapName",
            "table": "cmdb_ci_server",
            "status": "error",
            "error_message": "Target record not found",
            "status_message": "Row transform ignored by onBefore script"
        }
    ]
}

I guess it's happening because there is ignorance to true (which is strictly recommended by the docs .. otherwise it doesn't work properly)

SN docs: https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/product/configuration-management...

The Data Source that call the ServiceNow WS to import CI,expect the response in a format like this:

{
"ServerName" : "ServerName_Created_or_Updated",
"Status" : "Updated / Created"
}

 

Furthermore...

When the CI is previously discovered (and therefore with Discovery Source = ServiceNow), the Discovery Source field changes from "ServiceNow" to "MySource1", and I cannot see it on Discovery Schedule report as Discovered CI.

This no longer allows me to check whether a particular CI has actually been previously discovered except by using the Last discovere date column.

I should have more evidence of CI discovered by discovery but updated from other sources (as in my case). Is OOTB possible? Or do I have to create a custom report?

Best regards,

Gaetano

The suggested approach is for global scope import set table, transofrm script. If you are working on Scoped application, it will be little different. 

 

adilrathore
ServiceNow Employee
ServiceNow Employee

IRE is not Datasource specific. Also if you are using IRE the recociliation rules also work with that.

 

Why are you saying that Reconciliation rule will not work with REST API web service? Do you have any example to highlight this concern?