Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Script Include AssetandCI creates not unique CI when mac addres is populated

Marcin6
Tera Contributor

TL;DR: 
ci.name = asset.serial_number + ' - ' + asset.model.name; never happens when you provide the mac address

  createCIWithSerialNumber: function(asset, ci, assetCMDBUtil) {
        var relatedDataJson = '';
        if (AssetUtils.IS_ITAM_COMMON_ACTIVE && sn_itam_common.AssetCIHelper) {
            relatedDataJson = sn_itam_common.AssetCIHelper.getCIRLData(asset, ci);
            // ciDataobj is not empty then creation happens through IRE with serial number and mac address in this case.
            if (!gs.nil(relatedDataJson)) {
                return assetCMDBUtil.createCIUsingIRE(ci, relatedDataJson);
            }
        }
        ci.name = asset.serial_number + ' - ' + asset.model.name;
        return assetCMDBUtil.createCIUsingIRE(ci);
    },



Steps to reproduce:
- "create CI with IRE" is configured to true on the instance
- Import hardware asset or manually trigger BR: create Ci on insert, with asset that contains mac address information

Expectations: 
uniquely named CI is created 

Resoults:
CI is created with name set to model name only, as a resoult another import of asset with same model name fails due to IRE stopping from creating duplicates (depends on IRE configuration)

Is that known issue or it is expected that IRE should handle it somehow?

3 REPLIES 3

Laveena-Agarwal
Kilo Sage

Hi @Marcin6 

 

I think I can help you, can you structure the question, what you are trying to do and what is expected and actual behavior?

Marcin6
Tera Contributor

We batch import hardware assets and the incoming data contains:
- model name

- model number

- manufacturer

- serial number

- mac address
- location
- status

First record is created with success but the CI is named badly (only model name)

After importing first record with success other fail due to "duplicate CI found by IRE".  Which is correct becouse CI is not created with serial number + model name. It is created with name = model name only.

Imporant part:
As we tested it. This is not happening when we import hardware assets without mac address. createCIWithSerialNumber OOTB script goes correctly to naming action.

 

We are aware that and how above code can be fixed but this is "High Risk" OOTB code so we do not want to touch it.
We do not want to create workaround solutions for this for now unless

Can this be fixed by IRE configuration?

Best,
Marcin

Marcin6
Tera Contributor

I think the real issue hear is that CI created during the process has not unique name but should be unique by having unique mac address.

 

But the mac address is not set on CI itself but on referenced network adapters table. And yet IRE marks an attempt to create duplicate despite being provided with another mac address 



But IRE in next run does not