Skip to content

Commit

Permalink
Excluded additional object properties from get systemsettings retriev… (
Browse files Browse the repository at this point in the history
#337)

* 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
  • Loading branch information
seanmcne authored Oct 10, 2018
1 parent 823efac commit f149437
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f149437

Please sign in to comment.