Skip to content

Commit 1719eab

Browse files
committed
cleanup
1 parent a4d77e7 commit 1719eab

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ServiceNow/Public/Get-ServiceNowRecord.ps1

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,20 @@ function Get-ServiceNowRecord {
153153
# for each record, get the variable names and then get the variable values
154154
foreach ($record in $result) {
155155
$customVarParams = @{
156-
Table = 'sc_item_option_mtom'
157-
Properties = 'sc_item_option.item_option_new.name', 'sc_item_option.item_option_new.sys_name', 'sc_item_option.item_option_new.type'
158-
Filter = @('request_item', '-eq', $record.sys_id), 'and', @('sc_item_option.item_option_new.type', '-in', '1,2,3,4,5,6,7,8,9,10,16,18,21,22')
159-
First = 1000 # hopefully there isn't more custom vars than this...
156+
Table = 'sc_item_option_mtom'
157+
Property = 'sc_item_option.item_option_new.name', 'sc_item_option.item_option_new.sys_name', 'sc_item_option.item_option_new.type'
158+
Filter = @('request_item', '-eq', $record.sys_id), 'and', @('sc_item_option.item_option_new.type', '-in', '1,2,3,4,5,6,7,8,9,10,16,18,21,22')
159+
First = 1000 # hopefully there isn't more custom vars than this...
160160
}
161161
$customVars = Get-ServiceNowRecord @customVarParams
162162

163163
if ( $customVars ) {
164-
$customValues = Get-ServiceNowRecord -Table $Table -Filter @('sys_id', '-eq', $record.sys_id) -Properties ('variables.' + ($customVars.'sc_item_option.item_option_new.name' -join ',variables.'))
164+
$customValueParams = @{
165+
Table = $Table
166+
Filter = @('sys_id', '-eq', $record.sys_id)
167+
Property = $customVars.'sc_item_option.item_option_new.name' | ForEach-Object { "variables.$_" }
168+
}
169+
$customValues = Get-ServiceNowRecord @customValueParams
165170
$customValues | Get-Member -MemberType NoteProperty | ForEach-Object {
166171
$record | Add-Member @{
167172
$_.Name = $customValues."$($_.Name)"

0 commit comments

Comments
 (0)