How to filter services based on assignment group

ServiceNowL
Tera Contributor

We have a requirement to filter services (cmdb_ci_service) whose names contain 'SAP' when the SAP assignment group is selected on an incident record.

2 REPLIES 2

Daniel Borkowi1
Mega Sage

Hi @ServiceNowL,

 

I would recommend to create a Reference Qualifier where you can script your condition and which returns filter query. 

In Dictionary Override for field business_service in incident table set the Ref Qualifier:

DanielBorkowi1_7-1732087710524.png

 

Script Include to return the expected Services:

 

DanielBorkowi1_5-1732087086923.png

 

 

var TaskUtils = Class.create();
TaskUtils.prototype = Object.extendsObject(TaskUtilsSNC, {

    /***************Custom changes****************/
		
	getServiceQuery : function(current){
		var query = "";
		if(current.getDisplayValue("assignment_group").startsWith('SAP')){
			query += "nameSTARTSWITHSAP";

		}else{
			query = this.getConfigurationItemFilter(current);
		}
		return query;
	},
    type: 'TaskUtils'
});

 

 

Result:

DanielBorkowi1_4-1732087028316.png

 

But I would suggest to build more robust logic. Why you don't maintain the support group in the Service or the Service Offering. Then you can query for Services which contains the selected Assignment group. This will help in future to deliver similar results for other assignment groups.

Maintain Support Group in Service or Offering:

DanielBorkowi1_6-1732087357099.png

 

And Change Code in Script Include to this:

 

var TaskUtils = Class.create();
TaskUtils.prototype = Object.extendsObject(TaskUtilsSNC, {

    /***************Custom changes****************/
		
	getServiceQuery : function(current){
		var query = "";
		if(JSUtil.notNil(current.assignment_group)){
			query += "support_group=" + current.assignment_group;

		}else{
			query = this.getConfigurationItemFilter(current);
		}
		return query;
	},
    type: 'TaskUtils'
});

 

 

Greets 
Daniel

Please mark reply as Helpful/Correct, if applicable. Thanks!

Barry Kant
ServiceNow Employee
ServiceNow Employee

Good day, 
wondering if this is based on a technical initiated incident (2nd line, alert, provider). Otherwise I am missing to understand the requirement. 
Incidents created from consumer side in general do not know the assignment groups, they would be more familiar with Business Offerings. Then the Service will be the parent of the offering. 
Can you elaborate the reasoning of the requirement?