ecitsolutions / Autotask

A PowerShell module for Autotask Web Services API
MIT License
65 stars 18 forks source link

Filters with parenthesis no longer work #2

Closed creover closed 6 years ago

creover commented 6 years ago

For your example code that you provide:

$DueFrom = Get-Date $DueTo = $DueFrom.AddDays(3) $Tickets = Get-AtwsTicket -Filter {DueDateTime -gt $DueFrom -and DueDateTime -lt $DueTo} $OtherTickets = Get-AtwsTicket -Filter {Status -eq New -or (DueDateTime -gt $DueFrom -and DueDateTime -lt $DueTo)}

The following happens: ConvertTo-QueryXML : Cannot bind argument to parameter 'QueryText' because it is an empty string. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:179 char:22

You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:181 char:5

You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:195 char:7

You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:196 char:7

Method invocation failed because [System.String] does not contain a method named 'SetAttribute'. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:197 char:7

The property 'InnerText' cannot be found on this object. Verify that the property exists and can be set. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:198 char:7

The property 'InnerText' cannot be found on this object. Verify that the property exists and can be set. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:199 char:7

You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:200 char:7

Exception calling "query" with "1" argument(s): "System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.LoadXml(String xml) at AutotaskApiApplication.Contract.AutotaskApiService.InitializeFrameworkForRequest(String xmlRequest) at AutotaskApiApplication.API.V1_5.AutotaskApiService_1_5.query(String sXML) --- End of inner exception stack trace ---" At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:208 char:9

You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:219 char:9

The property 'InnerText' cannot be found on this object. Verify that the property exists and can be set. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:220 char:9

You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\Autotask\0.2.1.3\Public\Get-AtwsData.ps1:224 char:11

klemmestad commented 6 years ago

Thank you for reporting this.

I have fixed this and uploaded an updated module. Please note that I have found an error in our documentation on this point: Custom filters does not expand picklist values. The correct example should have been ('New' has been replaced by its numerical value):

$OtherTickets = Get-AtwsTicket -Filter {Status -eq 1 -or (DueDateTime -gt $DueFrom -and DueDateTime -lt $DueTo)}

This query should work with the newest module.