ecitsolutions / Autotask

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

Doc suggestion for null values #6

Closed AlexHeylin closed 6 years ago

AlexHeylin commented 6 years ago

Thanks for this module - very useful!

I hit a problem trying to query for null values (such as ticket.AssignedResourceID to mean unassigned). I found the docs sparse regarding null values, and typing prevents query by parameters from working.

This is more complex, but works - perhaps you'd add as an example to the docs. It gets unassigned tickets in our "1st line support" queue that have not been updated in two hours (set on line 2)

$AtDbUtcOffset = -4.0
$LastUpdateDateTimeEST = (get-date).AddHours(+$AtDbUTCOffset).AddHours(-2)
$Tickets1stLine = Get-AtwsTicket  -Filter { AssignedResourceID -isnull -and  QueueID -eq 29682833 -and (Status -eq 1 -or Status -eq 8 ) -and LastActivityDate -lt $LastUpdateDateTimeEST } 
$Tickets1stLine | ft AssignedResourceID , QueueID , TicketNumber, Title, LastActivityDate
klemmestad commented 6 years ago

Thank you! You are right, null values are not properly documented. I will try to get it updated as soon as time permits. Another weak point in our documentation is release notes. We have added support for null values in queries along the way, but it is not easy to find. Could I bother you to try this query to see if it gives you the same result as your query:

$AtDbUtcOffset = -4.0 $LastUpdateDateTimeEST = (get-date).AddHours(+$AtDbUTCOffset).AddHours(-2) $Tickets1stLine = Get-AtwsTicket -IsNull AssignedResourceID -QueueID <queuename> -Status <status 1>,<status 8> -LastActivityDate $LastUpdateDateTimeEST -LessThan LastActivityDate $Tickets1stLine | ft AssignedResourceID , QueueID , TicketNumber, Title, LastActivityDate1

AlexHeylin commented 6 years ago

Thanks for this. Sure, I'll run that tomorrow - just checking, do you want me to use the text lookup values, or the numeric IDs for queue name and statuses?

Thanks

Alex

On Tue, 29 May 2018, 21:37 Hugo Klemmestad, notifications@github.com wrote:

Thank you! You are right, null values are not properly documented. I will try to get it updated as soon as time permits. Another weak point in our documentation is release notes. We have added support for null values in queries along the way, but it is not easy to find. Could I bother you to try this query to see if it gives you the same result as your query:

$AtDbUtcOffset = -4.0 $LastUpdateDateTimeEST = (get-date).AddHours(+$AtDbUTCOffset).AddHours(-2) $Tickets1stLine = Get-AtwsTicket -IsNull AssignedResourceID -QueueID -Status <status 1>,<status 8> -LastActivityDate $LastUpdateDateTimeEST -LessThan LastActivityDate $Tickets1stLine | ft AssignedResourceID , QueueID , TicketNumber, Title, LastActivityDate1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/officecenter/Autotask/issues/6#issuecomment-392935011, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQifQCVVrH8wI5pvyWoS3yRxFkIA_Geks5t3bGKgaJpZM4URkPc .

klemmestad commented 6 years ago

Text values. Parameter validation will reject the numeric ids.

AlexHeylin commented 6 years ago

That works very well and is much easier to write and read. :-D Wishlist for the docs - examples of the less common operators (for example the -IsNull FieldName seems backwards to me), & full clear list of operators - I found myself trying to guess them and their syntax based on Autotask API docs. Thanks very much!

klemmestad commented 6 years ago

I have updated the documentation by adding a separate page where I try to explain how null values are handled. The documentation could still be improved, but I am closing this issue now.