script to assign tickets for users in a group with active tickets count is minimum to maximum
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2017 12:47 AM
hi, we have a requirement to run a schedule job everyday at 06 pm and should call a script include which queries all the active tickets in a customized table and assign to the users in a group. the tickets should be automatically assigned in such a way that it should assign to per with least active tickets assigned to him and should continue assigning tickets in incremental order of ticket count of the user.(say out of 20 active tickets with 15 users, first ticket should be assigned to user with 0 active tickets, next 1, 2, 3 active tickets of the user. please help me with the script.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2017 03:48 AM
Aniket gore, exactly the same, but instead of assigning to random user (when A=1, B=1, C=1), we will fetch the time on which 1 ticket is assigned to all three of them and user with old time value will get the ticket assigned
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2017 04:35 AM
Yes, that can be done by checking the row count of the gliderecord. I hope this solve your issue.
- Hit like if this solve your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2017 05:31 AM
Hi Krishna,
I was able to replicate the same scenario in my demo and was able to assign using the below script
var a= new GlideRecord('change_request');
a.addQuery('state',1);
a.addQuery('assignment_group','b85d44954a3623120004689b2d5dd60a');
//a.addNullQuery('assigned_to');b85d44954a3623120004689b2d5dd60a
a.query();
while(a.next())
{ if(a.assigned_to==''){
var b = new GlideRecord('sys_user_grmember');
b.addQuery('group','b85d44954a3623120004689b2d5dd60a');
b.query();
while(b.next())
{ var e= b.user;
e.sort();
gs.log('value'+e);
}
a.assigned_to=e;
a.update();
gs.log('ending'+ a.assigned_to);}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 02:34 AM
Hi swathi, thanks for the script.. really appreciate your time and efforts. but are you able to assign tickets to all users in ur instance? bcoz for me only few tickets are being assigned and other tickets remain unassigned.
So let me tell the requirement in case i miss any, if 13 tickets and 8 users are there, then first 5 users should get 2 tickets and next 3 users should get 3 tickets automatically assigned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 04:37 AM
yeah Krishna I tried this code ...but yes we have to add up and modify the codes with requirement ..I am also trying to get the output.
Can you just check on the script and see whether we can modify it or not.