ecitsolutions / Autotask

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

Get-AtwsTicket -SubIssueType not updating properly. #7

Closed sciorms closed 6 years ago

sciorms commented 6 years ago

This module is absolutely lovely and has definitely made our AT automation significantly more efficient. I've noticed a weird issue with AT tickets specifically with the "SubIssueType" parameter. I recently created a new subissuetype in AutoTask through the GUI labeled "Test" and I can assign it to tickets through the GUI without a problem.

When I use "set-atwsticket -ticketnumber $ticketnumber -subissuetype" I do not see the new subissue type populated. I re-connected to AT using "Connect-AutotaskWebAPI" to rebuild the dynamic module and I still did not see the subissuetype available through intellisense. I ran "get-help get-atwsticket" to view all of the different values for "subissuetype" and the list stops one before the new value that I've created.

I went ahead and uninstalled the module then re-installed with the "Install-Module" command I have not noticed a difference. I have not observed this behavior with other fields.

Is there a weird dependancy that I am missing that would explain why this specific field is not updating properly?

Edit:

When I look at the picklistvalues in Get-AtwsFieldInfo I can see the newly added fields but I still cannot access them through the subissuetype switch.

klemmestad commented 6 years ago

Ouch! You just made me realize we really need to improve our documentation. You need to refresh your offline cache of API functions: Connect-AutotaskWebAPI -RefreshCache

We create that offline cache because downloading field info on all Autotask entities from the API is just so darn slow, and we need field info to generate the right ValidateSet for fields such as subissuetype. You can connect without using offline cache, too: Connect-AutotaskWebAPI -NoDiskCache, but then you will have to wait for a complete download of all entities and field info on every connection.

This happens automatically whenever you upgrade you module or Autotask releases a new API version. If I knew how to detect an updated pick list parameter without waiting for field info on all entities I could have made this happen automatically whenever you change options such as subissuetype, but for now you have to do it manually (connect using -RefreshCache).

We are experimenting with PowerShell dynamic parameters to overcome this issue, but so far it looks like it would kill IntelliSense support in Visual Studio Code. It seems to work in PowerShell_ISE, so I am considering to make a separate module version with dynamic parameters. That would allow me to update parameters and field info at runtime, but that much dynamic code is quickly becoming a nitghtmare to debug... ;)

sciorms commented 6 years ago

This works perfectly! Thank you! I wasn't aware that there were switches for connect-autotaskwebapi to ignore the cache.