Round robin assigned
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 12:42 AM
HI All,
I want to ask how to create a round-robin type approach (Auto Assignment).
Here's my old script but not working.
Condition:
Script:
(function executeRule(current, previous /*null when async*/) {
var arrayUtil = new global.ArrayUtil();
var assignmentType = '';
var assignToThisUser = '';
var matchingRuleFound = false;
var matchingRuleSysID = '';
var getAssignmentRule = new GlideRecord('u_group_assignment_rule');
getAssignmentRule.addQuery('u_name', 'CDP_CCR_RR_assign');
//getAssignmentRule.addQuery('u_name', 'CDP_CCR_Alpha_RR_assign');
getAssignmentRule.query();
while(getAssignmentRule.next()){
assignmentType = getAssignmentRule.u_assignment_type;
matchingRuleSysID = getAssignmentRule.sys_id;
matchingRuleFound = true;
}
if (matchingRuleFound){
var asgUserList = []; //userlist of assignment group into array
//Need to look up the Group Members
gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',current.assignment_group);
gr.orderBy('user.first_name');
// gr.addQuery('u_exclude_assignment','false');
gr.addQuery('available','true');
gr.query();
while (gr.next()){
asgUserList.push(gr.getValue('user'));
}
if (assignmentType == 'Round Robin'){
var position = 0;
if (getAssignmentRule.u_round_robin_last_assigned == ''){
assignToThisUser = asgUserList[position];
}
else{
position = arrayUtil.indexOf(asgUserList, getAssignmentRule.u_round_robin_last_assigned); //get the index of the last assigned
position++;
if(position < asgUserList.length){
assignToThisUser = asgUserList[position];
}
else{
assignToThisUser = asgUserList[0];
}
}
}
var gr = new GlideRecord('x_amspi_cdp_request');
gr.addQuery('number',current.number);
gr.query();
while(gr.next())
{
gr.assigned_to = assignToThisUser;
gr.update();
}
}
})(current, previous);
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 12:52 AM
Hi @Uchel ,
Why dont you make sure of Advance work assignment module ?
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-29-2024 01:56 AM
Hi @Uchel
SN provide the AWA - Advance Work Assignment module, which help you to achieve this without any code. The only configuration is required .
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************