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.

How to exclude groups with "Copilot" or "ITIL" in name from a catalog item reference variable?

tilekarnilesh
Giga Guru

Hi everyone,

I'm trying to exclude user groups from a reference field in a Service Catalog item. Specifically, I want to hide any groups that contain "Copilot" or "ITIL" in their name.

Here's what I've done so far:

Variable Type: Reference

Reference: sys_user_group

Reference Qualifier: Advanced

Script I'm using:

(function() {
return "nameNOT LIKECopilot^nameNOT LIKEITIL";
})();

But this doesn't seem to be working — I still see groups.

Is this script wrong or does NOT LIKE not work reliably in catalog items?

Any help or alternate solution would be appreciated!

Thanks in advance.

tilekarnilesh_2-1746529385707.png

 

2 ACCEPTED SOLUTIONS

J Siva
Kilo Patron
Kilo Patron

Hi @tilekarnilesh 
You can use simple ref qualifier as below. It'll work.

JSiva_0-1746530452230.png

Regards,

Siva

 

View solution in original post

@tilekarnilesh 

Ok. If you want to use adv ref qualifier, then you need to use the below.

javascript:'nameNOT LIKECopilot^nameNOT LIKEITIL';

View solution in original post

3 REPLIES 3

J Siva
Kilo Patron
Kilo Patron

Hi @tilekarnilesh 
You can use simple ref qualifier as below. It'll work.

JSiva_0-1746530452230.png

Regards,

Siva

 

@J Siva 

Yes, I have achieved this using a simple approach, but I'm curious to understand how it works with an advanced reference qualifier and script. I want to learn how the scripting method functions under the hood.

@tilekarnilesh 

Ok. If you want to use adv ref qualifier, then you need to use the below.

javascript:'nameNOT LIKECopilot^nameNOT LIKEITIL';