Snow-Shell/servicenow-powershell

Custom Variable 'Reference' Type Value is Incorrect

RichardMawdsley opened this issue · 4 comments

Discussed in #217

Originally posted by RichardMawdsley December 7, 2022
Hi There,
Been using the CustomVariable option on the Get-ServiceNowRecord function for some time and it's working great. However, I'm unsure if I've found a bug or if it's just pulling the wrong information back, but what I'm getting is incorrect when the Type is 'Reference'.

$RITM = Get-ServiceNowRecord -ID $SNNumber -IncludeCustomVariable -New
$RITM.CustomVariable

Returns:

@{Value=ddf18f001b217700dfa575d6cc4bcb47; DisplayName=Location; Type=Reference}

When if I look in ServiceNow, the actual value is:

London - Main Office

Same is resulted without '-New' too. Unsure if it's related to the -DisplayValue parameter or this was supposed to resolve this very problem, but seemingly adding it causes the .customvariable to be empty.

I assume that what it's pulling is the ID or something of that value, but I'm not a ServiceNow admin so unsure on that. Thanks in advance.

Hi @RichardMawdsley. I assume the value being returned is the sysid for 'London - Main Office' in the Location lookup/table. If you can confirm, we can add this as an enhancement. This is expected as reference lookups for the underlying value require dot sourcing, if possible, or another call to the referenced table.

Hi @gdbarron , yes had it confirmed that this is the sysid. Much appreciated if this enhancement could be added!

@RichardMawdsley the update is in. Would you mind testing?

Perfect! Values are now getting returned exactly as expected. Thanks @gdbarron !