Is there a way to prevent hr case to assign to the person who opened it?

Evren Yamin
Tera Contributor

Hello,

There is an OOB automatic assignment of HR Case to a member of group who has the least task. But I notice that the case can be assigned to the same person who opened it.

Is there a way to prevent this? 

Thanks so much. Appreciate all the help.

1 ACCEPTED SOLUTION

Hi Evren,

I have adjusted the business rule and this is working for me with the default Matching rules:

(function executeRule(current, previous /*null when async*/) {
	
	if (current.skip_auto_assign)
		return; // assignment will be done via other means than this BR (e.g., workflow, manual)
	
	// see  "Matching Rules" menu item / module to configure assignment rules
	var matchingRuleProcessor = new global.MatchingRuleProcessor();
	var agents = matchingRuleProcessor.processAndGetCandidates(current, '2' ,'' ,'' ,true);
	if (agents && agents.length > 0) {
		current.assigned_to = agents[0];
		if (agents[0]==current.opened_by && agents[1]){
            current.assigned_to = agents[1];
        }
		else{
            current.assigned_to = agents[0];
        }
		gs.addInfoMessage(gs.getMessage('{0} was assigned to {1}.', [current.number, current.getDisplayValue('assigned_to')]));
	} else
		gs.addInfoMessage(gs.getMessage('No agents meet the auto-assignment criteria for {0}', current.number));
	
	
})(current, previous);

 

Can you try one last time? It is looking at the opened by, if that is the Agent it was initially assigning, it will assign to the 2nd result if we have it, that is what you want right?

As a fallback, if no secondary agent is found, it will use the default assignment and assign that agent.

View solution in original post

20 REPLIES 20

You can add the Table column to the list to see which table the Matching rule applies to.

At the bottom it will check the Assignment for HR Case, if it has not found a more specific rule:

find_real_file.png

For example the first one will call a function that gets agents by skill and matching country and orders them based on least loaded. Meaning it will assign to the user who has the least work yet.

The second one does almost the same but leaves out the country.

 

You could change that Matching rules, or disable them if you do not want to automatically assign.

 

If the mechanism is OK, but you just want to prevent assignment to the opened by user, you can adjust the business rule:

yourinstance.service-now.com/nav_to.do?uri=sys_script.do?sys_id=4c564cd79f221200d9011977677fcf4a

 

Change the script from:

(function executeRule(current, previous /*null when async*/) {
	
	if (current.skip_auto_assign)
		return; // assignment will be done via other means than this BR (e.g., workflow, manual)
	
	// see  "Matching Rules" menu item / module to configure assignment rules
	var matchingRuleProcessor = new global.MatchingRuleProcessor();
	var agents = matchingRuleProcessor.processAndGetCandidates(current,1);
	if (agents && agents.length > 0) {
		current.assigned_to = agents[0];
		gs.addInfoMessage(gs.getMessage('{0} was assigned to {1}.', [current.number, current.getDisplayValue('assigned_to')]));
	} else
		gs.addInfoMessage(gs.getMessage('No agents meet the auto-assignment criteria for {0}', current.number));
	
	
})(current, previous);

 

To this:

(function executeRule(current, previous /*null when async*/) {
	
	if (current.skip_auto_assign)
		return; // assignment will be done via other means than this BR (e.g., workflow, manual)
	
	// see  "Matching Rules" menu item / module to configure assignment rules
	var matchingRuleProcessor = new global.MatchingRuleProcessor();
	var agents = matchingRuleProcessor.processAndGetCandidates(current,1);
	if (agents && agents.length > 0) {
        if(agents[0]!=current.opened_by){
            current.assigned_to = agents[0];
        }
        else if (agents[1]){
            current.assigned_to = agents[1];
        }
		
		gs.addInfoMessage(gs.getMessage('{0} was assigned to {1}.', [current.number, current.getDisplayValue('assigned_to')]));
	} else
		gs.addInfoMessage(gs.getMessage('No agents meet the auto-assignment criteria for {0}', current.number));
	
	
})(current, previous);

 

Hi @Willem 

When I modified the business rule, it does not assign to the one who opened it but it also doesn't assign to other members of the group.

find_real_file.png

The group and user I'm using for test are all OOB. 

Hi Evren,

Sorry, forgot to update the user limit. It only returns 1.

 

Can you update it to this:

(function executeRule(current, previous /*null when async*/) {
	
	if (current.skip_auto_assign)
		return; // assignment will be done via other means than this BR (e.g., workflow, manual)
	
	// see  "Matching Rules" menu item / module to configure assignment rules
	var matchingRuleProcessor = new global.MatchingRuleProcessor();
	var agents = matchingRuleProcessor.processAndGetCandidates(current,2);
	if (agents && agents.length > 0) {
        if(agents[0]!=current.opened_by){
            current.assigned_to = agents[0];
        }
        else if (agents[1]){
            current.assigned_to = agents[1];
        }
		
		gs.addInfoMessage(gs.getMessage('{0} was assigned to {1}.', [current.number, current.getDisplayValue('assigned_to')]));
	} else
		gs.addInfoMessage(gs.getMessage('No agents meet the auto-assignment criteria for {0}', current.number));
	
	
})(current, previous);

Hi Willem,

Output still the same. I'm wondering if the problem is the setup of user but all I'm using are OOB. 

find_real_file.png

Hi Evren,

I have been testing as well. In my scenario I tested with Assignment group Tier 1. It always only returned Stephen Seiters as assignee. I figured out he was the only one with the Skill mentioned on the HR Case. Once I added the skills to others in the group, they show up as well.

So the adjustments I suggested will work, as long as there is another user with the same skills. Can you check if this is the case in your HR Case as well?

find_real_file.png

 

If this is the case, what do you want to do if the user opening the HR Case is the only user that matches the criteria?