Need help on updating the Model category in Asset

shaik_irfan
Tera Guru

Hi,

 

We have assets created now for few assets we wanted to change the model category from windows to linux

 

can anyone please help me how to do this ?

1 ACCEPTED SOLUTION

1. In Application Navigator, oepn "Asset". In the example below, I'm going to change Model category of if Lenovo ThinkServer TD230 From Windows Server to Linux Server.

find_real_file.png

2. Right click on the asset to change and select "Copy sys_id". Here, I've right clicked on "P1000196".

find_real_file.png

3. Next, find sys_id of Linux Server model category.

I'm just filtering list asset on "linux" to bring a record that has "Linux Server". Any record will do.

find_real_file.png

4. Open the record and right click on the header section and select "Copy sys_id". This is the sys_id of model category "Linux Server".

find_real_file.png

5. From Application Navigator, search and open "Script - Background".

find_real_file.png

6. Enter the script. Enter the sys_id of linuxModelClass and assetId as was found

from the above steps. After updating the script, click on "Run script".

find_real_file.png

7. Result of execution is displayed.

find_real_file.png

8. Check Asset list to make surethe Model category changed to Linux Server. 

find_real_file.png

 

 

 

View solution in original post

17 REPLIES 17

I think I now understand the question. It's keeping the model category intact and only change the asset.

There's a similar question about changing model category of an asset from Windows server to Linux server answered in the following thread.

https://community.servicenow.com/community?id=community_question&sys_id=0ff20ba1dbd8dbc01dcaf3231f96...

@Hitoshi Ozawa 

 

I did gone through that. 

 

There are 10 assets that has wrong model category can you please suggest the best way to do it ?

 

Do we need to update by fix script or i need to update at cmdb_model table ?

 

When i try to do it in my pdi i dont see that update the assets ?

 

 

Following script will update the Model category of an asset.

var linuxModelClass = '<sys_id of cmdb_ci_linux_server class>';
var assetId = '<sys_id of a record in alm_asset to change>';

var grHardware = new GlideRecord('alm_asset');
grHardware.addQuery('sys_id', assetId);
grHardware.query();
if (grHardware.next()) {
  grHardware.model_category = linuxModelClass;
  grHardware.update();
  gs.info("updated");
} else {
  gs.info("skipped");
}

@Hitoshi Ozawa 

 

Thank you for the reply. I can write a script but my worry is will that effect any exisitng workflow ?

 

As our client was Discovery in place will that cause any issues if we update the model categories through script ?

If the record was created by discovery, it would be better to delete the current assets that needs to be changed, fix the rule to match the alert with the CI and let the discovery create the CI and then asset over again.