Snow-Shell / servicenow-powershell

PowerShell module to automate ServiceNow service and asset management. This module can be used standalone, with Azure Automation, or Docker.
Apache License 2.0
359 stars 170 forks source link

Filtering on nested property doesn't work #200

Closed tobvil closed 2 years ago

tobvil commented 2 years ago

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.

gdbarron commented 2 years ago

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').

tobvil commented 2 years ago

Thanks for explaining @gdbarron! Works perfectly 👍