Snow-Shell/servicenow-powershell

Error with v3.4.3

Closed this issue · 3 comments

Discussed in #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 ...

@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.

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

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.