- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Is there a script to update the model category on multiple assets at once?
I have a script for single assets, but I currently need to update the model category on over 200 assets.
This is the script that works for updating the model category on individual assets from Computer to Mobile Device:
Any input would be helpful.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
If you only have/can get the sys_id of each asset, you could paste those in a comma-separated string to assign to assetId, then change the rest of the script to be more like this:
var grHardware = new GlideRecord('alm_asset');
grHardware.addQuery('sys_id', 'IN', assetId);
grHardware.query();
while (grHardware.next()) {
grHardware.model_category = mobiledeviceModelClass;
grHardware.update();
gs.info("updated");
} else {
gs.info("skipped");
}
An alternate approach is to use a System Data Management > Update Job in the left nav. You can identify the target assets based on a condition, or paste in your list of sys_ids, preview to make sure the count is right, then set the action in a no-code UI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
If you only have/can get the sys_id of each asset, you could paste those in a comma-separated string to assign to assetId, then change the rest of the script to be more like this:
var grHardware = new GlideRecord('alm_asset');
grHardware.addQuery('sys_id', 'IN', assetId);
grHardware.query();
while (grHardware.next()) {
grHardware.model_category = mobiledeviceModelClass;
grHardware.update();
gs.info("updated");
} else {
gs.info("skipped");
}
An alternate approach is to use a System Data Management > Update Job in the left nav. You can identify the target assets based on a condition, or paste in your list of sys_ids, preview to make sure the count is right, then set the action in a no-code UI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Your script worked. I had to take the "} else {" off the end of the script.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
59m ago
Script that was used for reference:
