Skip to content

Commit ee3038f

Browse files
authored
readme.md
The script finds all application records where the owner is inactive and updates their owner to the corresponding manager, ensuring that ownership is correctly assigned to an active user.
1 parent 9bdb77d commit ee3038f

File tree

1 file changed

+22
-0
lines changed
  • Scheduled Jobs/Update Inactive Application Owner

1 file changed

+22
-0
lines changed
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)