The CreatorCon Call for Content is officially open! Get started here.

I am unable to create or sync configuration item in alm_hardware table

PaladugulaM
Giga Contributor

Hi Team,

 

we are updating alm_hardware table through CSI integration, we can able to update only model. So we have written on After Transform script to update the model category and associated CI. with that script we can able to update only model category but CI is not creating I am giving my script below.  i have taken care of cross scoped application on alm_hardware an alm_asset table Could anyone will help in this.

 

(function(source, target) {

    var modelCategorySysId = "sys id of computer model category";
    var catGR = new GlideRecord("alm_hardware");
    catGR.addEncodedQuery("x_csili_int_csi_correlation_idISNOTEMPTY");
    catGR.query();
    catGR.setWorkflow(false);

    while (catGR.next()) {
        // Update the model category on the asset record
        gs.info("Processing asset: {0}", [catGR.asset_tag]);

        catGR.model_category = modelCategorySysId;
        catGR.update();

        var modelGr = catGR.model.getRefRecord();
        if (modelGr.isValidRecord()) {
            // Update the model category on the associated model record
            modelGr.cmdb_model_category = modelCategorySysId;
            modelGr.update();
        }
    }
    try {
        var assGR = new GlideRecord("alm_asset");
        (new AssetandCI()).createCI(assGR);
        gs.info("CI Created for asset: " + assGR.asset_tag);
    } catch (err) {
        gs.addErrorMessage("Error creating CI for asset " + assGR.asset_tag + ": " + err);
    }


})(source, target);

3 REPLIES 3

pavani_paluri
Giga Guru
Giga Guru

Hi @PaladugulaM ,

 

You havent selected any record for assGR

  var assGR = new GlideRecord("alm_asset");
        (new AssetandCI()).createCI(assGR);

 

Please check that

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

Kieran Anson
Kilo Patron

What stopped you from updating the model category? Needing to do multiple insert/update operations will hinder system performance.

 

In terms of your posted script, I assume the expectation is that your call to AssetandCI script include will create the necessary CI record. You're not currently passing in a single record, but an unfinished GlideRecord query. The following should work, assuming the target for the transform map is the asset record

 

new AssetandCI()).createCI(target)

 

PaladugulaM
Giga Contributor

I want to update the records, which i have updated the model categories, how can i achieve this.