Skip to content

Update Inactive Application Owner with their Manager #1606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var grApp = new GlideRecord("cmdb_ci_appl");
grApp.addEncodedQuery("owned_by.active=false");
grApp.query();
while(grApp.next()){
var managerSysId = grApp.owned_by.manager.toString(); // Get Manager SysId
if (managerSysId) {
grApp.owned_by = managerSysId;
grApp.update();
}
}
22 changes: 22 additions & 0 deletions Scheduled Jobs/Update Inactive Application Owner/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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.

**GlideRecord Initialization:**
var grApp = new GlideRecord("cmdb_ci_appl");

**Query for Inactive Owners:**
grApp.addEncodedQuery("owned_by.active=false");

**Executing the Query:**
grApp.query();

**Iterating Through Records:**
while(grApp.next()){

**Getting the Manager’s Sys ID:**
var managerSysId = grApp.owned_by.manager.toString();

**Updating the Owner:**
if (managerSysId) {
grApp.owned_by = managerSysId;
grApp.update();
}
Loading