
- 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 10:16 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2022 10:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2022 06:01 AM
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.