40 views

Description

HR matching rules / assignment logic don't work correctly if the user moving the case out of draft state doesn't have permission to read cases and therefore is unable to obtain a correct count of agent workload.

Steps to Reproduce

  1. For simplicity, install HR Core and HR SP without demo data.

  2. Add two users to HR Tier 1 and give them all HR skills.

  3. Remove location from the sys_user records for your agents.

  4. Find a set of users who have no HR roles and remove their location (eliminating the country matching part of assignment logic).

  5. Create a case as one of these users, and note who it was assigned to.

  6. Create a second case as a DIFFERENT non-HR user.

    It is important to be different as a user can view their own cases, so if you are the same user, then the count of caseload will be correct.

    If things are working properly, this case would go to the second agent. It may go to the second agent by happenstance, so keep creating cases for DIFFERENT end users with no HR roles until you see that the case load is not being distributed based upon agent workload.

 

Workaround

// below is the corrected function in script include sn_hr_core.hr_AssignmentUtil (sys id: 205cba709f221200d9011977677fcf21)
_sortAgentsByLeastLoaded: function(agents) {
var ids = [];
if (gs.nil(agents) || !agents.length)
return [];
try {
var assignCount = {};
var assignedTo;
var caseCount;
 
// get count of assigned cases per agent
var count = new GlideAggregate('task');
count.addQuery('assigned_to', 'IN', agents);
count.addQuery('active', 'true');
count.addQuery('sys_class_name', 'INSTANCEOF', 'sn_hr_core_case').addOrCondition('sys_class_name', 'INSTANCEOF', 'sn_hr_core_task');
count.addAggregate('COUNT', 'assigned_to');
count.orderByAggregate('COUNT', 'assigned_to');
count.query();
 
while (count.next()) {
assignedTo = count.assigned_to;
caseCount = parseInt(count.getAggregate('COUNT', 'assigned_to'));
assignCount[assignedTo] = caseCount;
}
 
// The query returns only those agents with assignments. Any agents not returned are added to list with a count of zero
var list = [];
for (var i = 0; i  < agents.length; i++) {
var id = agents[i];
var obj = {'id' : id};
var cnt = assignCount[id];
if (!gs.nil(cnt))
obj['value'] = cnt;
else
obj['value'] = 0;
list.push(obj);
}
//sort the list by count
list.sort(function (a, b) {
if (a.value > b.value)
return 1;
if (a.value < b.value)
return -1;
return 0;
});
 
for (var index = 0; index  < list.length; index++)
ids.push(list[index]['id']);
 
} catch (err) {
gs.error("Error in get agents by least loaded list: "+ err.message);
ids = agents;
}
return ids;
},

Related Problem: PRB1290209

Seen In

There is no data to report.

Intended Fix Version

Jakarta Patch 10
Kingston Patch 8

Fixed In

London

Safe Harbor Statement

This "Intended Fix Version" information is meant to outline ServiceNow's general product direction and should not be relied upon in making a purchasing decision. The information provided here is for information purposes only and may not be incorporated into any contract. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. The development, release, and timing of any features or functionality described for our products remains at ServiceNow's sole discretion.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-07-19 00:34:49
Published:2018-07-19