Assignment group should be auto populated in the Incident record, When Configuration item changes (Populate Configuration item Managed by group in the Incident Assignment group).

Amisha Pattojos
Tera Contributor

Assignment group should be auto populated in the Incident record, When Configuration item changes (Populate Configuration item Managed by group in the Incident Assignment group).

I'd really appreciate a descriptive walk through on how to solve it.

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Try something as below as a scalable option.

1. Script include: 

find_real_file.png

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

    GetCIGroup: function() {
        var ciselected = this.getParameter('sysparm_ci_grp');
        var as = new GlideRecord('cmdb_ci');
        as.addEncodedQuery('sys_id=' + ciselected );
        as.query();
        if (as.next()) {
            return as.managed_by_group.toString(); //will return sys_id of group
        }
    },

    type: 'getCIRelatedGroup'
});

 

 

2. Client script that runs onChange() of cmdb_ci field on incident form

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
   
    var ga = new GlideAjax("getCIRelatedGroup");
    ga.addParam("sysparm_name", "GetCIGroup");
    ga.addParam("sysparm_ci_grp", newValue);
    ga.getXML(parseResponse);
}

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

View solution in original post

5 REPLIES 5

Aman Kumar S
Kilo Patron

Hey,

I think Assignment rules, will be a good solution for your scenario.

Its simple, efficient , low code and OOTB way of doing assignments.

 

Below article suggests, how to create it:

https://docs.servicenow.com/bundle/quebec-it-service-management/page/product/incident-management/task/t_DefinAnAssignRuleIncidents.html

Best Regards
Aman Kumar

Jaspal Singh
Mega Patron
Mega Patron

Try something as below as a scalable option.

1. Script include: 

find_real_file.png

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

    GetCIGroup: function() {
        var ciselected = this.getParameter('sysparm_ci_grp');
        var as = new GlideRecord('cmdb_ci');
        as.addEncodedQuery('sys_id=' + ciselected );
        as.query();
        if (as.next()) {
            return as.managed_by_group.toString(); //will return sys_id of group
        }
    },

    type: 'getCIRelatedGroup'
});

 

 

2. Client script that runs onChange() of cmdb_ci field on incident form

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
   
    var ga = new GlideAjax("getCIRelatedGroup");
    ga.addParam("sysparm_name", "GetCIGroup");
    ga.addParam("sysparm_ci_grp", newValue);
    ga.getXML(parseResponse);
}

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

What changes I need to make in the script if "Managed by" group is inactive, I need to assign Incident to user's location deskside?

 

 

Ketan Patel1
Tera Contributor

Hello,

Don't forget to check out Data Lookup Rules.