- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 01:01 AM
Hi All,
I need to remove value from field in many records and I want to do this by Background Script.
Field from which I need to remove value is 'operational_status' in Servers:
The issue is that when I open the record then in every record table in different so I think I need to use cmdb_ci table and I war trying by below script:
var test = new GlideRecord("cmdb_ci");
test.addEncodedQuery('operational_status=1^correlation_idLIKESYS_'); //When operational status is operational and Source ID contains SYS_
test.query();
if(test.next()){
test.setValue("operational_status", "");
test.setWorkflow(false); //Do not run business rules
test.update();
}
but it showed that it works only for one record...
How can I resolve this?
Thanks in advance for help!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 01:08 AM
var test = new GlideRecord("cmdb_ci");
test.addEncodedQuery('operational_status=1^correlation_idLIKESYS_'); //When operational status is operational and Source ID contains SYS_
test.query();
if(test.next()){ // you need to use while here instead of if to loop multiple records
test.setValue("operational_status", "");
test.setWorkflow(false); //Do not run business rules
test.update();
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 01:08 AM
var test = new GlideRecord("cmdb_ci");
test.addEncodedQuery('operational_status=1^correlation_idLIKESYS_'); //When operational status is operational and Source ID contains SYS_
test.query();
if(test.next()){ // you need to use while here instead of if to loop multiple records
test.setValue("operational_status", "");
test.setWorkflow(false); //Do not run business rules
test.update();
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 01:16 AM
It works! Thank you! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2024 11:42 PM
thanks so much