How to I change the model category for an asset - does not appear to be enabled out-of-the-box

timt
Kilo Contributor

I have several physical server assets (eg. Windows Servers)... where we have re-allocated them as Linux Servers.   I can change the class on the CI... but the model category on the corresponding asset is still 'Windows Server'.  

This doesn't appear to be enabled, even for adminstrators, 'out of the box'.     I assume it's because the complexity and rules & processing around asset/ci creation.

 How can I update the Asset record with the correct model category?

1 ACCEPTED SOLUTION

jake_mckenna
ServiceNow Employee

You are correct that there is nothing there and makes sense that the function or type of sever is not defined or changes during the lifecycle. In the past I have added a business rule on the cmdb_ci table to look for changes in class and has an asset record to do something like this below:



updateAssetMC();


function updateAssetMC(){


  var asset = current.asset;


  var newClass = getModelCat(current.sys_class_name);



  var gr = new GlideRecord('alm_asset');


  gr.addQuery('sys_id',asset);


  gr.query();


  if(gr.next()){


  if(newClass){


  gr.model_category = newClass;


  gr.update();


  }


  }


}




function getModelCat(c){


  var gr = new GlideRecord('cmdb_model_category');


  gr.addQuery('cmdb_ci_class',c);


  gr.query();


  if(gr.next()){


  return gr.sys_id;


  }


}


View solution in original post

10 REPLIES 10

There is a YT Video that tells you how you can update it per record

 

Theres a YT Video that tells you how to update it by record

 

Updating the Model Category of an Existing Asset in ServiceNow - YouTube