Snow-Shell/servicenow-powershell

Get-ServiceNowRecord -Filter not functioning as expected

ajacks88 opened this issue · 3 comments

Apologies if this is something simple, i had been using your module back when Get-ServiceNowTable was a thing and it worked great. I am attempting to update my scripts to use the new Get-ServiceNowRecord but am having some trouble. Here is what im running (after authenticating)

Get-ServiceNowRecord -table cmdb_ci_server -Filter @('name', '-eq', 'someservername')

However, what i get back from this cmdlet is 10 server records, all of which have no name at all.

Am i missing something?

What i used to run was : Get-ServiceNowTable -Table cmdb_ci_server -Query "name=$servername" and it worked like a charm.

I just tried the same command and worked for me. What version of the module are you using? What version of powershell? Can you run with -verbose and provide output please? All the details on the bug report issue would be helpful.

I'm getting the same problem using v3.1.9

Example:
Get-ServiceNowRecord -Table 'Change Request' -Filter @('assigned_to', '-eq', 'Kenneth Jones')

Or using:
Get-ServiceNowRecord -Table 'Change Request' -Filter @('assigned_to', '-like', 'Kenneth Jones')

It responds with 10 RFC (not even CHG tickets) and none of these are assigned to Kenneth Jones.

I found the issue and will be fixing it shortly. The issue was with the filter not applying correctly in certain circumstances.

@wwwb0n3zcom, while there is an issue with the filter not applying, there is also an issue with how you are calling the filter. assigned_to is a reference field and you must either provide the sys_id to compare against or dot-walk if you want to compare against a field in the reference. See the example:

image