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

That seems overkill for a one-off data correction.  Best practice not to hard-code sys_id values is for scripts that would be reused and/or migrated across instances.  There is no risk to running a one-off script to correct data using a hard-coded ID, and no value in creating a system property to support that.


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

@Paul Coste I suggested using system property in case the user opts for Fix-script 🙂 

Mitch McCain
Tera Contributor

 

I use a transform map coalesce on the serial number/asset tag to update the models. I'm sure the scripts mentioned above are viable solutions as well.

I experience this often since we create shell asset records from advance shipping notices prior to the CIs being discovered. When a mismatch occurs, I use a transform map to change the asset record model to match the CI model ID. If this is a one off without a linked CI then it's easier to delete and recreate but if there are many and/or associated with a CI then this is a more efficient approach that can be handled by the asset analyst.