Execute assignment rule on demand by script

Piero Virgilio
Tera Expert

Hi All,

the client asked me to implement a UI action to suggest an assignment group to the agent after changing some fields of the case (Business Service and other custom fields).

Is there a way to execute on-demand assignment rules, which I have defined to assign the case when it is created, and show the result to the agent who can decide whether or not to accept the suggestion?

I don't want the assignment group of the case always be recalculated on update.

Thanks,
Piero.

1 ACCEPTED SOLUTION

Piero Virgilio
Tera Expert

I've found the solution using GlideFilter.checkRecord() and GlideScopedEvaluator().evaluateScript() functions.

checkRecord allows me to find the assignment rule that match with new values of my record.

evaluateScript returns me the sys_id of the calculated group.

Thanks all for the support,
Piero

View solution in original post

8 REPLIES 8

sachin_namjoshi
Kilo Patron
Kilo Patron

you can configure business rule to show message with assignment group name.

this BR can lookup assignment rules lookup table data configured on your instance.

 

Regards,

Sachin

Some of the assignment rules that I've defined are scripted, so I need to match the exact one and get its response

Baala T
Mega Guru

Hi Piero,

As we aware that Assignment Lookup Rules are stored in dl_u_assignment tables, I have tried with UI Action and Script.

UI Action

Name : Assignment Group

Table : Incident

Client : true

OnClick : openEligibleAssignmentGroups()

Script:

function openEligibleAssignmentGroups() {
	var ajaxHelper = new GlideAjax('AssignmentGroupLookupAjax');
	ajaxHelper.addParam('sysparm_name', 'getEligibleAssignmentGroups');
	ajaxHelper.addParam('sysparm_category', g_form.getValue('category'));
	ajaxHelper.getXML(showEligibleAssignmentGroups);
}

function showEligibleAssignmentGroups(response) {
	var answer = response.responseXML.documentElement.getAttribute('answer');
	
    var refurl = reflistOpenUrl('incident.assignment_group', 'incident.assignment_group', 'sys_user_group', 'sys_user_group', 'null', 'false', '');
    var url = 'sys_idIN' + answer;
    var refurlquery = refurl + url;

	popupOpenStandard(refurlquery, 'lookup');
}

Script Include:

Name : AssignmentGroupLookupAjax

Client Callable : true

Script:

var AssignmentGroupLookupAjax = Class.create();
AssignmentGroupLookupAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getEligibleAssignmentGroups: function() {
        var grAGL = new GlideRecord('dl_u_assignment');
        grAGL.addQuery('category', this.getParameter('sysparm_category'));
        grAGL.query();
		
        var answer = "";
        while (grAGL.next()) {
            if (answer != "")
                answer += ",";
			
            answer += grAGL.assignment_group;
        }

        return answer;
    },

    type: 'AssignmentGroupLookupAjax'
});

 

Output you can get it, as below. When you click on "Assignment Group" the popup window will open with eligible assignment groups, when you click the chosen assignment group will get set Assignment Group in Incident form.

find_real_file.png

 

Regards,
Bala T

zag
Tera Expert

Off the top of my head I'd say use Flow Designer. Force the client to work out the process and visualize what they are asking. With Flow designer you have all the If/Else if option you need and actions to support it.