Auto populate Assignment Group

Joshuu
Kilo Sage

Hi All,

 

We are populating assignment group on incident form based on the CI that was selected on form (From "cmdb_rel_group" table). Below are the scripts that were written for the same.

 

Client script: On Change on Incident Table

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    //if (isLoading || newValue === '') {
    if (newValue === '') {
        return;
    }
    var ga = new GlideAjax('SetAssignmentGroup'); //script include name
    ga.addParam('sysparm_name', 'populateAssignmentGroup'); //script include function name
    ga.addParam('sysparm_cmdb_ci', g_form.getValue('cmdb_ci')); //parameter passeed
    ga.getXML(getResponse);

    function getResponse(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        g_form.setValue('assignment_group', answer);
    }
}

 

 

Script Include:

 

var SetAssignmentGroup = Class.create();
SetAssignmentGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
populateAssignmentGroup : function(){
var gr=new GlideRecord('cmdb_rel_group');
gr.addQuery('ci',this.getParameter('sysparm_cmdb_ci'));
	gr.query();
if(gr.next())
{
return gr.group;
}

},
type: 'SetAssignmentGroup'
});

 

 

So, the assignment group is automatically populating based on the ci that was selected on the incident form. And We need this functionality to work even for an inbound integration with another ServiceNow instance.

 

The group is automatically populating whenever an incident is created through integration. But, now the problem is we are unable to populate the assignment group whenever we update the incident through inbound integration, the form is not getting saved/updated. So, we can see the value on the form but the value is not changing from the incident's list view and also unable to see it in the history as well.

 

Any solution is appreciated.

 

Please help.

 

Thanks,

Priya.

 

9 REPLIES 9

Mike_R
Kilo Patron
Kilo Patron

Is the integration setting the assignment group or are you expecting the CIient script to run? Client scripts on run when users are interacting with the form. They will not work for integrations.

 

Hi Mike,

 

Thanks for the clarification. Yes I was expecting this client script to run for integrations as well to populate the assignment group.

 

But I am not sure why is it not working properly only for update. Because when any incident is getting created through integration the group is automatically populating. And even for update also it is populating on form but not saving/updating the record.

 

Any suggestions, how can we achieve this ?

 

Thanks,

Priya.

I would try using assignment rules, and if that doesn't work create a business rule.

Patrick Laroch1
Giga Guru

Why are you not using OOTB assignment rules?