Snow-Shell / servicenow-powershell

PowerShell module to automate ServiceNow service and asset management. This module can be used standalone, with Azure Automation, or Docker.
Apache License 2.0
359 stars 170 forks source link

Error with v3.4.3 #234

Closed gdbarron closed 1 year ago

gdbarron commented 1 year ago

Discussed in https://github.com/Snow-Shell/servicenow-powershell/discussions/222

Originally posted by **DrMarkX** December 20, 2022 From my question #192 I am now getting several 'ID' errors when using this line. `Get-ServiceNowRecord -Table sc_req_item -filter @('number', '-in', ($tasks.'request_item.number'[0..48] -join ',')) -IncludeCustomVariable -Property number -IncludeTotalCount` After several iterations of that error, the correct output is displayed. **Error** Get-ServiceNowRecord : Cannot validate argument on parameter 'ID'. Id must be either a 32 character alphanumeric, ServiceNow sysid, or prefix/id, ServiceNow number. At C:\Program Files\WindowsPowerShell\Modules\ServiceNow\3.4.3\Public\Get-ServiceNowRecord.ps1:357 char:126 + ... on.item_option_new.reference' -ID $var.'sc_item_option.value' -Proper ...
gdbarron commented 1 year ago

@DrMarkX, I've found the issue, but unable to recreate. For some reason the reference value for a reference type custom variable is not a sysid, I have not seen this before. When the type is a reference, I've added in 'ReferenceTable' and error handling. I'm hoping this will help us narrow down the issue.

Can you test with the script you provided in the discussion and see which entries have a ReferenceTable value and 'Value' is not a sysid? The updated code can be found at https://github.com/Snow-Shell/servicenow-powershell/blob/234-error-with-v343/ServiceNow/Public/Get-ServiceNowRecord.ps1.

gdbarron commented 1 year ago

Hi @DrMarkX, just following up, if/when you get time...

DrMarkX commented 1 year ago

I am so sorry I haven't responded. I did some testing, and the error is not showing. I also caught an issue where I was passing a null value to the user table - which also displayed error messages.