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 when using -IncludeCustomVariable: Id must either be a SysId 32 character alphanumeric or Number with prefix and id. #262

Closed CATgwalker closed 2 months ago

CATgwalker commented 5 months ago

Environment

Operating System: Windows 11
ServiceNow module version: 4.0.3
PowerShell version: 5.1

Steps to reproduce

Include custom variables on a request or catalog item that are blank, not filled out or otherwise do not have a "value" returned from sc_item_option_mtom.

This is a continuation of #234.

Expected behavior

The custom variable is not further enumerated in the sc_item_option_mtom table and not added to $record.CustomVariable result object. The original sc_item_option.Value id number should be retained for performing additional metadata lookup later on if needed

Actual behavior

Throws error listed below - this can occur multiple times for each custom variable on a catalog item that does not have a "value"

Get-ServiceNowRecord : Cannot validate argument on parameter 'ID'. Id must either be a SysId 32 character alphanumeric or Number with prefix and id.
At C:\Users\...\Documents\WindowsPowerShell\Modules\ServiceNow\4.0.3\Public\Get-ServiceNowRecord.ps1:368 char:117
+ ... on.item_option_new.reference' -ID $var.'sc_item_option.value' -Proper ...
+                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-ServiceNowRecord], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Get-ServiceNowRecord

Screenshots

image image image