Hardware Asset update

Ralton Stewart
Tera Guru

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.

 

 

 

 

1 ACCEPTED SOLUTION

Alex Tod1
Kilo Sage

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');

View solution in original post

5 REPLIES 5

Ralton Stewart
Tera Guru

Hey All I will try the solution soon and report back