Is it possible to use an if/else in a reference qualifier?

Erik Nelson
Kilo Sage

I have a list collecter variable that currently is set to only display members of a selected assignment group.  This is great as long as the group is in ServiceNow.  Part of the build is for items that won't be an assignment group, but still uses the user lookup.

Can something be setup in the Reference Qualifier to the effect of "javascript:if(current.variables.var1=X no filtering);else(Group_member(current.variables.var2):

If that's not possible, should it be looking to client script, or similar to do the work?

Thanks!

Erik

1 ACCEPTED SOLUTION

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

script includes aren't necessary... Yes is it possible and there are many out of the box fields with them.  I have learned best by looking at out of the box examples over the last many years.  Navigate to System Definition \ dictionary and search where reference qual contain "if" for many examples.

View solution in original post

9 REPLIES 9

Thanks and noted for the future...I wussed out and went script include

Erik Nelson
Kilo Sage

Thanks Elijah and Michael,

I was hoping to avoid using a client script and following Michael's suggestion I was able to.  

My original example script was pretty close to what I needed, and having the reference to the dictionary was what I needed.

New Example: 

javascript:if(current.variables.var1 == 'x')Group_member(current.variables.var2); else'active=true';

This worked for us with modification on enclosing the first qualifier in ''. Thanks!

javascript:if(current.variables.var1 == 'x')'<qualifier 1 here>'; else'<qualifier 2 here>';
 
 

Hi All,

I used your defined reference qualifier for my condition at the variable level and it works however it has got some additional condition to place like

Reference qualifier is based on Group table and user don't want to see groups of type request_approval whether it is ADD or REMOVE.

I am trying like this

javascript:if(current.variables.add_remove=="Remove")
"typeNOT LIKE1baabd380ff02a8843881efae1050e44^sys_idIN"+gs.getUser().getUserByID(current.variables.requested_for).getMyGroups().toArray().join();

else

"typeNOT LIKE1baabd380ff02a8843881efae1050e44";

But it didn't work. Do I need to write script include and do the filter or doing any amendment on the existing query will work.

Any help will be much appreciated!!!

 

 

NowUtil
Tera Contributor

Hi JC S

 

javascript&colon;if(current.variables.var1 == 'x')'<qualifier 1 here>'; else'<qualifier 2 here>';

 

here what is Qualifier 1 and qualifier 2?