Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Auto populate Assignment group based on CI related item service support group

Reddy34
Tera Contributor

Hi All,

 

I have a requirement to populate the assignment group based on CI related item Service support group .

see below screen  shorts.

 

1. In the Incident form open the Configuration item 

Reddy34_0-1693240775031.png

2. Open services related items under that CI

Reddy34_1-1693240847440.png

3. See the service Group in that 

Reddy34_2-1693240934460.png

 

4. That assignment group need to populate Incident form assignment group

 

Kindly suggested me on this ,

Thank you !

 

 

 

8 REPLIES 8

Danny Mortensen
Tera Contributor

The suggested Client Scripts are not a bad solution if you want assignment group to be populated immediately rather than after you save the record, but be careful you are not trumping OOTB functionality.

There is OOTB functionality already in place to do what you are after. There is an OOTB business rule named "Populate Assignment Group based on CI/SO" which will populate the assignment group based on a change of either the Service Offering or the CI. This happens server side so the assignment group is populated after you save the record.


Sri Harsha2
Tera Expert

Hi @Reddy34 ,

We can do it many ways, one way is to write Script Include and On change client script as provided below,

onChange Client ScriptonChange Client ScriptScript IncludeScript Include

If my response has resolved your query, please consider giving it a thumbs up ‌‌and marking it as the correct answer‌‌!


Thanks & Regards,

Sriharsha.

Kishore47
Tera Contributor

Script Includes

 

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

    getCiSupportGroup: function() {
        var ciID = this.getParameter('sysparm_ci');
        obj = {};
        var ciRec = new GlideRecord('cmdb_ci');
        if (ciRec.get(ciID)) {

            obj.supportG = ciRec.getValue('support_group');
           
        }
        return JSON.stringify(obj);
    },
    type: 'ciCheckSupportGrouop'
});
 
onChange Client script on Configuration Item
 
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var ga = new GlideAjax('ciCheckSupportGrouop');
    ga.addParam('sysparm_name', 'getCiSupportGroup');
    ga.addParam('sysparm_ci', g_form.getValue('cmdb_ci'));
    ga.getXMLAnswer(getResponse);


    function getResponse(response) {
        var res = JSON.parse(response);
        g_form.setValue('assignment_group', res.supportG);
       
    }
}
 
If my answer helped, please mark it helpful and correct. Thanks!
 

JaganN971616731
Tera Contributor

Hi @Reddy34 ,

 

Could you please tell me how did you add multiple related items under CI? Can we add multiple assignment group in related item under CI? PFA attached a snap below. I want the same configuration.

JaganN971616731_0-1725463072971.png

 

Thanks,

Jagan