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

Hi Patrick,

 

Will the OOTB assignment rules work for integrations as well ? and can we save/update the record after populating the group on form?

 

Please help.

ricker
Tera Guru

Priyarao,

Assignment rules are the way to go.

Umasankar Guth1
Tera Contributor

Hi Priya,

 

Just use OOTB assignment lookup rules.

 

below is the example.

 

create a rule with CI information and what group to populate.

UmasankarGuth1_1-1665154514658.png

and you can see on incident form it will populate based on CI selected.

UmasankarGuth1_2-1665154556941.png

Please mark helpful if my solution helps.

AEterni
Mega Guru

Hi,

 

I think you can achieve your goal using a flow.

 

If I understand it properly, you want the assignment group to be populated whenever the "Configuration item" field is populated (or changed), correct?

 

If that's the case, I think you can try with a flow that looks like this.

AlessandroEter_0-1665216695976.png

 

  • In the trigger you should select the right condition. In your case "Assignment Group" is empty.
  • In the look up action you look up in your cmdb table with a condition like "Configuration Item" = the configuration item in the incident you have selected in the trigger
  • In the Update action, you should update the assignment group of the incident you selected in the trigger with the assignment group you have (I assume) mapped in your cmdb table.

 

Cheers. 

 

 

Pavankumar_1
Mega Patron

Hi @Joshuu ,

Client scripts will not work for Inbound integrations. 

You can achieve using Async Business rule.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar