-
Notifications
You must be signed in to change notification settings - Fork 908
Schedulejob inactivegroup cleanup #1831
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
Schedulejob inactivegroup cleanup #1831
Conversation
This schedule script will execute monthly, weekly or bi-weekly as frequency is scheduled to identify all the groups that are not referenced in any Task(INC/PRD/CHG/RITM) in last 6 month and mark them INACTIVE. This activity has been carried out as cleanup activity for groups that are not in use and consuming license role
This schedule script will execute monthly, weekly or bi-weekly as frequency is scheduled to identify all the groups that are not referenced in any Task(INC/PRD/CHG/RITM) past 6 months for analysis and inactivate them after analysis What it does and how it can add value ? - Find out the groups that are inactive and not updated in last 6 months. Get the group names as a comma seprated array - Check if the group has any task assigned in the last 6 months (tasks that were created after the date 6 months ago.) - Get the list as Output of all inactive group names as a comma-separated string Benifits: This activity has been carried out as cleanup activity for groups that are not in use and consuming license role
WillemZeiler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your submission. I have added comments to the script. Feel free to make the requested adjustments and re-submit the PR. For now I will close this PR.
| @@ -0,0 +1,9 @@ | |||
| This schedule script will execute monthly, weekly or bi-weekly as frequency is scheduled to identify all the groups that are not referenced in any Task(INC/PRD/CHG/RITM) past 6 months for analysis and inactivate them after analysis | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot inactivate an inactive group. Can you update this description? What is it you are doing with the Inactive group array? From the code it is a list of inactive groups, that have no tasks assigned. What about inactive groups that have tasks assigned?
| var groupName = grGroups.getValue('name'); | ||
|
|
||
| // Check if the group has any task assigned in the last 6 months | ||
| var taskCheck = new GlideAggregate('task'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are looking through all tasks, closed or open, why is that? An inactive group with closed tasks to it's name would still be inactive, correct? So perhaps add a check for open tasks or closed in the past 6 months?
| var inactiveGroups = []; | ||
|
|
||
| var grGroups = new GlideRecord('sys_user_group'); | ||
| grGroups.addInactiveQuery(); // To find all groups that are Active = False in sys_user_group table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combination of line 7 + 8 does not work or is not needed, as this will just return all records.
It would make sense to only look at Active groups, that do not have any open tasks for the past 6 months.
| - Get the list as Output of all inactive group names as a comma-separated string | ||
|
|
||
| Benifits: | ||
| This activity has been carried out as cleanup activity for groups that are not in use and consuming license role |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a disclaimer as licence consumption is something to be cautious in making statements about. You are not covering all groups that are active in the system, but should be inactive. F.e. there could be an assignment done to an Active tasks to a team that is now not in use anymore. With a disclaimer it will help people to understand it is an helpful tool, but no guarantees.
| // Check if the group has any task assigned in the last 6 months | ||
| var taskCheck = new GlideAggregate('task'); | ||
| taskCheck.addQuery('assignment_group', groupSysId); //filter to only include tasks where the assignment group matches the current group's sys_id. | ||
| taskCheck.addQuery('sys_created_on', '>', sixMonthsAgo); //filter to only include tasks that were created after the date 6 months ago. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you think of a way to make the six months lookback variable? Different companies/teams might have a different definition of inactive. f.e. 3 moths or 9 months etc.
PR Description: Find out the groups that are inactive and not updated in last 6 months. Print the group names as a comma seprated array .
This schedule script will execute monthly, weekly or bi-weekly as frequency is scheduled to identify all the groups that are not referenced in any Task(INC/PRD/CHG/RITM) in last 6 month and mark them INACTIVE.
This activity has been carried out as cleanup activity for groups that are not in use and consuming license role
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions