Advanced record qualifier with 3 conditions

dowson
Tera Expert

I am having trouble with a catalog item reference qualifier with three different conditions.

The desired returned results are:

1. Apple Mac assets assigned to the requested for user that are 4 years old or more

2. Windows assets assigned to the requested for user that are 3 years old or more

3. Assets assigned to the user running Windows 10 of any age.

I can get the first two to work:

javascript:(function(){var req=current.variables.requested_for;return 'assigned_to='+req+'^display_nameSTARTSWITHApple Mac^purchase_dateRELATIVELT@year@ago@4^NQassigned_to='+req+'^ci.osSTARTSWITHWindows^purchase_dateRELATIVELT@year@ago@3';})(); 

But my attempts to add the third possible condition (or even simplify for now to just 1. and 3. as there are no retireable windows 11 computers yet) all return unexpected results, most often all windows assets.

1 ACCEPTED SOLUTION

I was able to resolve this using related fields.

Here's my working query:

javascript:(function(){var req=current.variables.requested_for;return 'assigned_to='+req+'^ci.ref_cmdb_ci_computer.os=Windows 10^NQassigned_to='+req+'^display_nameSTARTSWITHApple Mac^purchase_dateRELATIVELT@year@ago@4^NQassigned_to='+req+'^ci.ref_cmdb_ci_computer.osSTARTSWITHWindows^purchase_dateRELATIVELT@year@ago@3';})(); 

View solution in original post

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

What have you tried?  First manually filter a list view on just criteria 3, hard-coding or selecting a user, to confirm the records that are returned are expected, then copy the query from the breadcrumb (right-click, copy query) to append to this after the @3 with the same overall OR that you used earlier.  It seems like it should be

javascript:var req=current.variables.requested_for;return 'assigned_to='+req+'^display_nameSTARTSWITHApple Mac^purchase_dateRELATIVELT@year@ago@4^NQassigned_to='+req+'^ci.osSTARTSWITHWindows^purchase_dateRELATIVELT@year@ago@3^NQassigned_to='+req+'^ci.os=Windows 10;

 

Ankur Bawiskar
Tera Patron
Tera Patron

@dowson 

did you try forming the filter condition on table list and then try to use that in advanced ref qualifier

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

I was able to resolve this using related fields.

Here's my working query:

javascript:(function(){var req=current.variables.requested_for;return 'assigned_to='+req+'^ci.ref_cmdb_ci_computer.os=Windows 10^NQassigned_to='+req+'^display_nameSTARTSWITHApple Mac^purchase_dateRELATIVELT@year@ago@4^NQassigned_to='+req+'^ci.ref_cmdb_ci_computer.osSTARTSWITHWindows^purchase_dateRELATIVELT@year@ago@3';})();