Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. NewInclude.prototype = {
  2. initialize : function() {
  3. },
  4. newInclude: function()
  5. {
  6.  
  7. var usersWithTasks = [];
  8. var userWithoutTask = [];
  9. var res;
  10. var taskAgg = new GlideAggregate('task');
  11. taskAgg.addAggregate('COUNT');
  12. taskAgg.addQuery('sys_created_by', '!=', '');
  13. taskAgg.groupBy('sys_created_by');
  14. var allCreatedBy = 0;
  15. taskAgg.query();
  16. while(taskAgg.next()) {
  17. usersWithTasks.push(taskAgg.getValue('sys_created_by'));
  18. allCreatedBy++;
  19. }
  20.  
  21. var usersAll = new GlideRecord('sys_user');
  22. usersAll.addQuery('user_name', '!=', '');
  23. usersAll.addQuery('active', 'true');
  24. usersAll.query();
  25. while(usersAll.next()) {
  26. var userID = usersAll.getValue('user_name');
  27.  
  28. if (usersWithTasks.indexOf(userID) === -1) {
  29. userWithoutTask.push(usersAll.getValue('sys_id'));
  30. }
  31. }
  32.  
  33. //gs.log("PNA " + userWithoutTask);
  34.  
  35. return 'sys_idIN'+ userWithoutTask.toString();
  36. },
  37.  
  38. type : 'NewInclude'
  39. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement