Skip to content

Commit bec2666

Browse files
authored
Update Inactive Application Owner with their Manager (#1606)
1 parent 6dda7de commit bec2666

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var grApp = new GlideRecord("cmdb_ci_appl");
2+
grApp.addEncodedQuery("owned_by.active=false");
3+
grApp.query();
4+
while(grApp.next()){
5+
var managerSysId = grApp.owned_by.manager.toString(); // Get Manager SysId
6+
if (managerSysId) {
7+
grApp.owned_by = managerSysId;
8+
grApp.update();
9+
}
10+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
This code snippet will update the owner of application records in the cmdb_ci_appl table where the current owner is inactive. It specifically sets the owner to the manager of that inactive owner, ensuring that each application has an active owner assigned.
2+
3+
**GlideRecord Initialization:**
4+
var grApp = new GlideRecord("cmdb_ci_appl");
5+
6+
**Query for Inactive Owners:**
7+
grApp.addEncodedQuery("owned_by.active=false");
8+
9+
**Executing the Query:**
10+
grApp.query();
11+
12+
**Iterating Through Records:**
13+
while(grApp.next()){
14+
15+
**Getting the Manager’s Sys ID:**
16+
var managerSysId = grApp.owned_by.manager.toString();
17+
18+
**Updating the Owner:**
19+
if (managerSysId) {
20+
grApp.owned_by = managerSysId;
21+
grApp.update();
22+
}

0 commit comments

Comments
 (0)