Find all tasks associated to users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2014 07:49 AM
I have an issue with duplicate users in our system. My goal is to find all the users who do not have any tasks, CIs, Approvals, etc tied to them and delete those users. Then, I will configure our coalesce to work accurately based on the systems we import from.
I've search the Wiki and Community, but haven't found anything that will tell me how to find these users. Any help will be much appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2014 07:09 AM
Mike - Thank you for your suggestions. I am using a non-prod instance cloned from prod to troubleshoot. Unfortunately, my scripting abilites are very minimal so I'm trying to take what you and mguy have suggested and get this issue fixed. Please let me know if the information below is in the right direction.
- Create 3 integer fields on the sys_user table called CI, tasks, and approvals
- Create 3 count aggregate queries as below to populate these fields and run them as background-scripts
- Run conditions on the user table looking for users with "0" in these 3 fields and delete those users
var task = new GlideAggregate('task');
task.addQuery('assigned_to', 'users sys_id');
task.addAggregate('COUNT');
task.query()
var tickets = 0;
if (task.next())
tickets = task.getAggregate('COUNT');
NOTES:
- I'm not sure how to tell the script to populate the COUNT into the fields
- Do I need a script for when the user is the opened by, opened for, caller, ect as per the list of related lists in my earlier post?
Thank you very much for your help!