Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-ServiceNowRecord -Filter not functioning as expected #183

Closed
ajacks88 opened this issue Mar 31, 2022 · 3 comments
Closed

Get-ServiceNowRecord -Filter not functioning as expected #183

ajacks88 opened this issue Mar 31, 2022 · 3 comments
Assignees
Labels

Comments

@ajacks88
Copy link

ajacks88 commented Mar 31, 2022

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.

@gdbarron
Copy link
Collaborator

gdbarron commented Apr 1, 2022

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.

@wwwb0n3zcom
Copy link

wwwb0n3zcom commented Apr 7, 2022

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.

@gdbarron gdbarron self-assigned this Apr 11, 2022
@gdbarron gdbarron added the bug label Apr 11, 2022
@gdbarron
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants