The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Issue with updating CI name through Bulk upload

kalpeshjs
Tera Contributor

Hi,

 I have created a bulk upload template for updating Asset records. In the bulk upload template, I have one field as “Name” through which I am updating "Configuration Item" field on alm_hardware table and the "Name"  is getting updated on “cmdb_ci” table. The issue which I am facing is if the Configuration Item is same then it is updating the records correctly. Only if the Configuration Item is different then instead of updating the record it is creating a new CI on cmdb table and that to also under wrong class as Configuration Item.

Please can some one help me on the this and how can I resolve this. Serial number is the “Coalesce” field.

kalpeshjs_0-1742572714421.png

 

Onbefore

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    if (source.u_name) {

        gs.log("Looking for CI with name: " + source.u_name, "Test Hardware Upload Transform");

        var ci = new GlideRecord('cmdb_ci');

        ci.addQuery('name', source.u_name);

        ci.query();

        if (ci.next()) {

            gs.log("Found CI with sys_id: " + ci.sys_id, "Test Hardware Upload Transform");

            target.ci = ci.sys_id;

        } else {

            gs.log("CI with name " + source.u_name + " not found.", "Test Hardware Upload Transform");

        }

    }

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

 

onAfter

(function runTransformScript(source, map, log, target) {

    if (source.u_name && target.ci) {

        gs.log("Updating CI with sys_id: " + target.ci + " to name: " + source.u_name, "Test Hardware Upload Transform");

        var ci = new GlideRecord('cmdb_ci');

        if (ci.get(target.ci)) {

            ci.name = source.u_name;

            ci.update();

            gs.log("CI updated successfully.", "Test Hardware Upload Transform");

        } else {

            gs.log("CI with sys_id " + target.ci + " not found.", "Test Hardware Upload Transform");

        }

    }

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

0 REPLIES 0