Snow-Shell/servicenow-powershell

Filtering on nested property doesn't work

tobvil opened this issue · 2 comments

Environment

Operating System: Windows 11
ServiceNow module version: 3.4.0
PowerShell version: 7.2.5

Steps to reproduce

Get-ServiceNowRecord -Table 'Requested Item' -Filter @('cat_item.link','-eq','https://servicenow.com/api/now/table/sc_cat_item/randomid')

Expected behavior

Should return request items with the specified catalog item link.

Filtering works fine on properties that are not nested. I.e short_description or state. But cat_item contains 2 properties. display_value and link.

Actual behavior

Returns all request items. Filter is not working at all.

Hi @tobvil. The issue is this is a reference field and the data returned are references to the item, not properties of the item. Neither display_value nor link are actual properties of that item. If you dot walk one of the actual properties it will work for you. Eg. Get-ServiceNowRecord -Table 'Requested Item' -Filter @('cat_item.sys_id','-eq','randomid').

Thanks for explaining @gdbarron! Works perfectly 👍