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.

Add Criteria AND Sort to Catalog Item Reference Field

jmiskey
Kilo Sage

I have a reference field in my Catalog Item.  I want to only show record where the Inactive field (u_inactive) is False, and I want to sort it by the Order field (u_order).

I changed the "Use reference qualifier" on the Reference Variable to "Advanced", then enter this in the Reference qual field:

u_inactive=false^ORDERBYu_order

But it did not work.  Actually, the criteria portion DID work correctly, but the sort part did not.

At first, I just used "Simple" for the "User reference qualifier", and set the criteria there, but then I wasn't sure how to get the sort portion to work along with that.

How do I get both of these things to work at the same time?

Thanks

2 REPLIES 2

jmiskey
Kilo Sage

So, if I change the "Use reference qualifier" back to "Simple", I see it gives me conditions for both Criteria and Sort.  But the sorting is still not working properly.

I came across another way that looks like you can sort using the "Variable attributes".  So I put this in the "Variable attributes".

ref_ac_order_by=u_sort

But it STILL does not work!

No matter what I do, it seems to want to sort it alphabetically by the name of Display field!

In case it helps, here are the 4 custom fields I added to this table I created:

find_real_file.png

I want this Reference Variable to sort the options by the "Order" field, but it keeps sorting based on the "LDAP Instance" field.

OK, it appears that I had a serious brain cramp.

The name of my sort field is "u_order", not "u_sort".  Trying the last method I mentioned, when I changed that in my "Variable attributes", it work as intended.

Problem solved.