Skip to content

Commit 3c213a9

Browse files
Update BG Scripts - Bulk Update Tables.js
This Background script will help to update the Incident table in bulk if condition are matched
1 parent 4bcf607 commit 3c213a9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Background Scripts/Bulk Update Tables/BG Scripts - Bulk Update Tables.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
function bulkUpdate('incident', 'active=true^priority=3',) {
1+
// Bulk update function to update records in any table
2+
function bulkUpdate(table, query, data) {
23
if (!table || !query || typeof data !== 'object') {
34
gs.error("Invalid parameters provided to bulkUpdate function.");
45
return;
56
}
67

7-
var gr = new GlideRecord(incident);
8+
var gr = new GlideRecord(table);
89
gr.addEncodedQuery(query);
910
gr.query();
1011

@@ -25,3 +26,10 @@ function bulkUpdate('incident', 'active=true^priority=3',) {
2526

2627
gs.info("Bulk update completed. Total records updated: " + count);
2728
}
29+
30+
// Call the function to update incidents:
31+
// Where active = true, priority = 3, and category = network
32+
bulkUpdate('incident', 'active=true^priority=1^category=Hardware', {
33+
state: 2, // Typically "In Progress"
34+
comments: 'Updated via bulk update script'
35+
});

0 commit comments

Comments
 (0)