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.

Reference Qualifier on Catalog Item

Nishant16
Tera Expert

I need to dynamically set reference qualifier on a Catalog item based on the variable options. Variable " Request Type" has options "internal" and "external"

When i select Request type as "Internal" then i need to show the reference field values of Variable 'Application' restricting only to values Configuration items{cmdb_ci} having Assignment group as " ABC"

when Request type selected as "External" then show CI's which have assignment group as "XYZ"

How can i achieve this?

2 REPLIES 2

Mohith Devatte
Tera Sage
Tera Sage

hello Nishant,

you need to call a advanced reference qualifier for this in application field like below 

Create a script include which is not client callable

 

javascript:new your_Script_include_name().your_function_name(current.variables.your_request_type_variable_backend_name);

script include:(Non client callable):

your_function_name:function(type)

{

var arr=[];

if(type=="internal") // replace internal choice value name
{
getCI('your_ABC group sys_id');
}
else if(type=="external") // replace external choice value name
{
getCI('your XYZ group sys_id');
}


function getCI(groupID)
{
var gr = new GlideRecord('cmdb_ci');

gr.addQuery('assignment_group',groupID); // replace your assignment group field name in the query.

gr.query();

while(gr.next())

{

arr.push(gr.sys_id.toString());

}
}

return "sys_idIN"+arr;

},

Hope this helps 

please mark my answer correct if this helps you

Hope this helps 

Michael Jones -
Giga Sage

Assuming your Request Type variable has the name request_type and the actual values are lower-case, you can use something like this

On your CMDB variable, set the attribute ref_qual_elements=request_type this will make the system re-evaluate the ref when you change the field. 


For the Reference Qualifier, use something like this 

javascript: request_type == "internal" ? "assignment_group=<sys_id for group ABC" : "assignment_group=<sys_id for group XYZ"

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!