
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 09:15 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 09:43 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 09:34 AM
Go to the related CI and from that record change the Model ID field. This will update the model on the asset record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 09:43 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 11:49 AM
Thanks Paul, this is exactly what I was looking for!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 10:11 AM
You can try the
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();
}