- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2022 02:32 AM
How can I change state from open to closed incomplete for all requests, requested items & catalog task table's records (whose state is currently open), I need to do this in bulk via script
please, anyone, provide help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2023 01:22 AM
You can write this as fix script
var gr = new GlideRecord("sc_request");
gr.addQuery("state", "1");
gr.query();
while (gr.next()) {
gr.state = 4;
gr.update();
var gr1 = new GlideRecord("sc_req_item");
gr1.addQuery('request',gr.sys_id);
gr1.addQuery("state", "1");
gr1.query();
while (gr1.next()) {
gr1.state = 4;
gr1.update();
}
var gr2 = new GlideRecord("sc_task");
gr2.addQuery('request',gr.sys_id);
gr2.addQuery("state", "1");
gr2.query();
if (gr2.next()) {
gr2.state = 4;
gr2.update();
}
}
Bharath Chintala

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2022 01:17 PM
You can use the GlideRecord API. Set your query using addQuery() and perform the update using updateMultiple().
Here's a great article on it:
Pro Tip: Use updateMultiple() for Maximum Efficiency!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2023 01:22 AM
You can write this as fix script
var gr = new GlideRecord("sc_request");
gr.addQuery("state", "1");
gr.query();
while (gr.next()) {
gr.state = 4;
gr.update();
var gr1 = new GlideRecord("sc_req_item");
gr1.addQuery('request',gr.sys_id);
gr1.addQuery("state", "1");
gr1.query();
while (gr1.next()) {
gr1.state = 4;
gr1.update();
}
var gr2 = new GlideRecord("sc_task");
gr2.addQuery('request',gr.sys_id);
gr2.addQuery("state", "1");
gr2.query();
if (gr2.next()) {
gr2.state = 4;
gr2.update();
}
}
Bharath Chintala