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

Willem
Giga Sage
Giga Sage

Have you checked HR Assignment Rules?:

find_real_file.png

 

Also check out this business rule:

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

 

It will assign based on the HR Matching rules:

find_real_file.png

Do you see an info message when it is assigned?

In your case it is a HR Matching rule I think.

It evaluates the Active rules in order:

find_real_file.png

 

Let me know if you need any help with this.

Hi @Willem 

The message that I can see is from the business rule "Auto-assign".

I'm new to this and the scripting used in the matching rules is really confusing but I can understand that it gets the user that is a member of the group and it gets the member with the least of task assignments.

Where should I put the condition to prevent the assignment to the one who opened it?

 

Hi @Evren Yamin I have posted the script changes in an additional comment. Can you check that out?

What it does is, check if the agent that the script comes up with is the opened_by user. If it is not, it will set it as the assigned to. If it is the same user, it will check the second agent suggested and if the second agent is available, set that as the assigned to.

Hope this helps 🙂