From f149437ce682beede2c595c83b2e037e2c968fa5 Mon Sep 17 00:00:00 2001 From: Sean McNellis Date: Wed, 10 Oct 2018 16:47:49 -0500 Subject: [PATCH] =?UTF-8?q?Excluded=20additional=20object=20properties=20f?= =?UTF-8?q?rom=20get=20systemsettings=20retriev=E2=80=A6=20(#337)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Excluded additional object properties from get systemsettings retrieve by fetch logic. Longer term we may wish to consider going away from serializaing these inside the function and, instead, rely on the object returned from get-CrmRecordsByFetch * Added null check on the name property to avoid this in the future --- .../Microsoft.Xrm.Data.PowerShell.psm1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 index da4e02a..4d51cf4 100644 --- a/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 +++ b/Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1 @@ -3470,7 +3470,7 @@ function Get-CrmSystemSettings{ foreach($att in $record.original.GetEnumerator()) { - if(($att.Key.Contains("Property")) -or ($att.Key -eq "organizationid")) + if(($att.Key.Contains("Property")) -or ($att.Key -eq "organizationid") -or ($att.Key.StartsWith("ReturnProperty_")) -or ($att.Key -eq "logicalname") -or ($att.Key -eq "original")) { continue } @@ -3518,7 +3518,13 @@ function Get-CrmSystemSettings{ { $name = ($attributes | where {$_.LogicalName -eq $att.Key}).SchemaName } - Add-Member -InputObject $psobj -MemberType NoteProperty -Name $name -Value $record.($att.Key) + + if($name -eq $null){ + Write-Warning "SKIPPING Property: $($att.Key)" + } + else{ + Add-Member -InputObject $psobj -MemberType NoteProperty -Name $name -Value $record.($att.Key) + } } return $psobj