Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 04:09 AM
I am in need of fix script to change all hardware assets that has state of Allocated-primary system, and Allocate-secondary system and change it to state in use.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2023 04:13 AM
Hi @Ralton Stewart!
The code should look something like this:
// Query for hardware assets with the specified states
var hardwareAssets = new GlideRecord('alm_hardware');
hardwareAssets.addQuery('state', 'IN', ['Allocated-primary system', 'Allocate-secondary system']);
hardwareAssets.query();
// Update each hardware asset to the 'In use' state
while (hardwareAssets.next()) {
hardwareAssets.state = 'In use';
hardwareAssets.update();
gs.info('Updated hardware asset ' + hardwareAssets.getDisplayValue() + ' to In use');
}
gs.info('Script completed');
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 01:11 AM
Hey All I will try the solution soon and report back