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

https://docs.servicenow.com/bundle/sandiego-platform-administration/page/administer/task-table/task/t_DataLookupRule.html