On a Ref Qualifier Override. I need a dynamic ref qual based on the Assignment Group on the Incident Form

JM316
Mega Sage

Hi All,

On the Task form is the Business Service reference field to cmdb_ci_service.

Today, I have an override ref qual on the Business Service Field when the form is the Incident so when you click on the lookup you are returned certain business service. This Ref Qual works:

javascript: "operational_status=1^"+ (current.category.nil() ? 'u_incident_categoryISNOTEMPTY' : 'u_incident_category=' + current.category)

Now I need this Ref Qual to be 'dynamic'.

If the assignment_group is "A" then the Ref Qual should only be where "operational_status=1"

ELSE the Ref Qual should remain

 javascript: "operational_status=1^"+ (current.category.nil() ? 'u_incident_categoryISNOTEMPTY' : 'u_incident_category=' + current.category)

There should be enough space in the Ref Qual field to accommodate an IF statement but every attempt I've tried does not work.

I have tried called a script include, but that has not worked either.

 

1 ACCEPTED SOLUTION

 

 

I took a stab at it real quick. So the ref qual would look something like:

javascript: new TestScriptInclude().businessServiceRefQual(current);

And the script include:

var TestScriptInclude = Class.create();
TestScriptInclude.prototype = {
    initialize: function() {
    },
	
	businessServiceRefQual: function(incident) {
		var query = '';
		if(incident.assignment_group == '3647376ddbb58b04f8d57fc88c961975')
			query = 'operational_status=1';
		else
			if(JSUtil.nil(incident.category))
				query = 'operational_status=1^u_incident_categoryISNOTEMPTY';
			else
				query = 'operational_status=1^u_incident_category= ' + incident.category;
		
		return query;
	},

    type: 'TestScriptInclude'
};

View solution in original post

6 REPLIES 6

 

 

I took a stab at it real quick. So the ref qual would look something like:

javascript: new TestScriptInclude().businessServiceRefQual(current);

And the script include:

var TestScriptInclude = Class.create();
TestScriptInclude.prototype = {
    initialize: function() {
    },
	
	businessServiceRefQual: function(incident) {
		var query = '';
		if(incident.assignment_group == '3647376ddbb58b04f8d57fc88c961975')
			query = 'operational_status=1';
		else
			if(JSUtil.nil(incident.category))
				query = 'operational_status=1^u_incident_categoryISNOTEMPTY';
			else
				query = 'operational_status=1^u_incident_category= ' + incident.category;
		
		return query;
	},

    type: 'TestScriptInclude'
};

Thanks Ryan.

I spent some more time last night and this morning.

I must have had a space or weird character.

But when I manually re-entered the syntax referring to your script it then worked.

I really appreciate the help.