How to expand MakeandModelJS to add model number checking?

treidfrb
Kilo Guru

Hello ITAM/CMDB colleagues,

I wanted to share a success I had with a support ticket and the MakeandModelJS script include, and pose a question. There is a community post here

 

https://community.servicenow.com/community?id=community_question&sys_id=2077cb69db1cdbc01dcaf3231f96...

that talks about MakeandModelJS.  My support ticket gave a guidance on the usage, and I have found two things.

1) the code given contains an if statement with triple equal signs, which works when you test in background scripts, but does not work in the SCCM integration in the instance.  Remove one equal sign making it two equal signs, and it works.  It does test out either way in Background Scripts, so you cannot rely on Background Scripts in some cases, always be skeptical of this.

2) Matching on manufacturer and model name alone is not enough.  Many model names have multiple model numbers, so when I used the code in the SCCM integration, i need to match on manufacturer, model name, and model number.  Since this is an OOB feature I will need to go back to Support for this.  Has anybody else used MakeandModelJS in the SCCM integration to match models?  SCCM is providing only a model number in u_model in the SCCM source data, so I am implementing a lookup table using these if statement matches on the value of u_model.

In the attachment you see I have to use "ThinkCentre M93P 01" to make the model name lookup unique for this particular model number.  Doing it this way works, but I don't want to have to modify my model names like this.  I should be matching on Model name and Model Number in the hardware model table.

Thanks

2 ACCEPTED SOLUTIONS

Closing this in lieu of upgrading to San Diego and upgrading our SCCM integration from "SCCM 2012 v2" to "Service Graph connector for Microsoft SCCM (3.0.6)".  The enhancement appears to not have moved forward, but may have had some impact on ITAM development...

Tim

View solution in original post

Hi @Houston Vargas,

 

Sorry for the delayed response.

 

I updated the "CmdbIntegrationHardwareModelUtil" Script Include to add the following new function:

// Customisation for model number
cleanseModelNumberAndCompany: function(companyName, modelName, modelNumber) {
	
        var result = {};

        if (!modelName && !companyName)
            return result;

        if (!modelName && companyName)
            return this.cleanseCompany(companyName);
		
        if (companyName)
            companyName = new CmdbIntegrationCompanyModelUtil().cleanseCompany(companyName);

        var mmn = new sn_cmdb_int_util.MakeAndModelAndNumberJs().fromNames(companyName, modelName, modelNumber, "hardware");

        result.modelSysId = gs.nil(mmn.model_id_sys_id) ? '' : mmn.model_id_sys_id;
        result.modelName = gs.nil(mmn.model_id_name) ? '' : mmn.model_id_name;

        result.companySysId = gs.nil(mmn.manufacturer_sys_id) ? '' : mmn.manufacturer_sys_id;
        result.companyName = gs.nil(mmn.manufacturer_name) ? '' : mmn.manufacturer_name;

        return result;
    },

 

The "Cleanse Hardware Model" RTE Operation Type I updated as follows to include the lines commented with Customisation  for model number:

(function(batch, output) {

    for (var i = 0; i < batch.length; i++) {

        // input is manufacturer name then model name in order
        var manufacturer_in = batch[i].input_0;
        var model_in = batch[i].input_1;
	// Customisation for model number
		var model_num_in = batch[i].input_2;

        if (!manufacturer_in && !model_in) {
            output[i] = '';
            continue;
        }

		// Customisation for model number
		var result;
		if ((manufacturer_in == 'LENOVO' || manufacturer_in == 'Lenovo') && model_num_in) {
			result = new sn_cmdb_int_util.CmdbIntegrationHardwareModelUtil().cleanseModelNumberAndCompany(manufacturer_in, model_in, model_num_in);
		} else {
			result = new sn_cmdb_int_util.CmdbIntegrationHardwareModelUtil().cleanseModelAndCompany(manufacturer_in, model_in);
		}

        if (!result) {
            output[i] = '';
            continue;
        }

        var companyName = result.companyName ? result.companyName : '';
        var companySysId = result.companySysId ? result.companySysId : '';
        var modelName = result.modelName ? result.modelName : '';
        var modelSysId = result.modelSysId ? result.modelSysId : '';

        // output is <core_company.sys_id>|||<core_company.name>|||<cmdb_model.sys_id>|||<cmdb_model.name>
        output[i] = companySysId + "|||" + companyName + "|||" + modelSysId + "|||" + modelName;
    }
})(batch, output);

 

The "Cleanse manufacturer" Robust Transform Engine Entity Cleanse Hardware Model Operation was modified to add "u_productversion" to the list of Source Fields:

Cleanse_hardware_RTE.png

I hope this helps.

Dean.

View solution in original post

11 REPLIES 11

treidfrb
Kilo Guru

FYI on this issue.

 

FTASK41371 has been opened

 

This enhancement request will allow future users of the SCCM Integration to match incoming values in source.u_model from SCCM with values in the model name or model number field in the hardware model table.  Lenovo desktops and laptops tend to send only a model number from SCCM, and searching SCCM, there isn't any model name field present in the source data.

 

HTH

Tim

With the new Content Libraries with HAMP, this opens up a whole bunch more of possiblies to get even more precise model identification and creation via the makeandmodeljs() api.  

Can you be a little more specific? Provide additional information

Closing this in lieu of upgrading to San Diego and upgrading our SCCM integration from "SCCM 2012 v2" to "Service Graph connector for Microsoft SCCM (3.0.6)".  The enhancement appears to not have moved forward, but may have had some impact on ITAM development...

Tim