Update Asset Model - ACL or Script?

Jon Collins2
Kilo Sage

Hi folks, 

We had a technician accidentally create a laptop asset under the wrong hardware model, and now we need to move it to the correct model. Given that there is an OOTB ACL that prevents changing models after asset creation, would I be better off modifying the ACL, or using a script to change this asset's model?

If scripting is the better choice, can anyone assist with a basic script write up for this?

Thanks in advance.

1 ACCEPTED SOLUTION

CMDB Whisperer
Mega Sage
Mega Sage

If you have a CI associated with the Asset you can change it from the CI side.  If you do not have a CI associated with the Asset, you will need to write a script.  A simple background script should be sufficient if it was a one-off. 

Do not change the ACLs.  That would be like changing the official hours of operation for a store because someone asked to be allowed inside after closing time because they forgot their coat.

Here is a sample script:

var assetID = '00a96c0d3790200044e0bfc8bcbe5dc3'; //Asset that you want to change
var modelID = 'd501454f1b1310002502fbcd2c071334'; //Correct model reference
var grAH = new GlideRecord('alm_hardware');
if (grAH.get(assetID)) {
    grAH.setValue('model', modelID);
    grAH.update();
}

Please mark this as Helpful and/or Correct Response if this addressed your question.


The opinions expressed here are the opinions of the author, and are not endorsed by ServiceNow or any other employer, company, or entity.

View solution in original post

7 REPLIES 7

Ken Neikirk1
Tera Guru

Go to the related CI and from that record change the Model ID field.  This will update the model on the asset record.

CMDB Whisperer
Mega Sage
Mega Sage

If you have a CI associated with the Asset you can change it from the CI side.  If you do not have a CI associated with the Asset, you will need to write a script.  A simple background script should be sufficient if it was a one-off. 

Do not change the ACLs.  That would be like changing the official hours of operation for a store because someone asked to be allowed inside after closing time because they forgot their coat.

Here is a sample script:

var assetID = '00a96c0d3790200044e0bfc8bcbe5dc3'; //Asset that you want to change
var modelID = 'd501454f1b1310002502fbcd2c071334'; //Correct model reference
var grAH = new GlideRecord('alm_hardware');
if (grAH.get(assetID)) {
    grAH.setValue('model', modelID);
    grAH.update();
}

Please mark this as Helpful and/or Correct Response if this addressed your question.


The opinions expressed here are the opinions of the author, and are not endorsed by ServiceNow or any other employer, company, or entity.

Thanks Paul, this is exactly what I was looking for!

Sai Kumar B
Mega Sage
Mega Sage

@Jon Collins 

You can try the @Paul Coste script however, calling sys_id's directly in the script is not a best practice. Instead, store them in system property and call them via gs.getProperty('property.name')

Modification to the above Sample Script:

var assetID = gs.getProperty('property.name1'); //Asset that you want to change
var modelID = gs.getProperty('property.name2'); //Correct model reference
var grAH = new GlideRecord('alm_hardware');
if (grAH.get(assetID)) {
    grAH.setValue('model', modelID);
    grAH.update();
}