Skip to content

Commit d440807

Browse files
authored
hotfix to support no mapped fields on delete (#27)
1 parent c4de60d commit d440807

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

delete.ps1

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,27 @@ function ConvertTo-FlatObject {
116116
try {
117117
#region account
118118
# Define account object
119-
$account = [PSCustomObject]$actionContext.Data.PsObject.Copy()
120-
121-
# Define properties to query
122-
$accountPropertiesToQuery = @("id") + $outputContext.Data.PsObject.Properties.Name | Select-Object -Unique
123-
124-
# Remove properties of account object with null-values
125-
$account.PsObject.Properties | ForEach-Object {
126-
# Remove properties with null-values
127-
if ($_.Value -eq $null) {
128-
$account.PsObject.Properties.Remove("$($_.Name)")
119+
if ($actionContext.Data -ne $null) {
120+
$account = [PSCustomObject]$actionContext.Data.PsObject.Copy()
121+
122+
# Remove properties of account object with null-values
123+
$account.PsObject.Properties | ForEach-Object {
124+
# Remove properties with null-values
125+
if ($_.Value -eq $null) {
126+
$account.PsObject.Properties.Remove("$($_.Name)")
127+
}
129128
}
130-
}
131-
# Convert the properties of account object containing "TRUE" or "FALSE" to boolean
132-
$account = Convert-StringToBoolean $account
129+
# Convert the properties of account object containing "TRUE" or "FALSE" to boolean
130+
$account = Convert-StringToBoolean $account
131+
132+
# Define properties to compare for update
133+
$accountPropertiesToCompare = ConvertTo-FlatObject -Object $account | Get-Member -MemberType Properties | Select-Object -ExpandProperty Name
134+
}
133135

134-
# Define properties to compare for update
135-
$accountPropertiesToCompare = ConvertTo-FlatObject -Object $account | Get-Member -MemberType Properties | Select-Object -ExpandProperty Name
136+
# Define properties to query
137+
# Automatically replaced by HelloID for compatibility with release 2025.04
138+
# $accountPropertiesToQuery = @("id") + $account.PsObject.Properties.Name | Select-Object -Unique
139+
$accountPropertiesToQuery = @("id") + $outputContext.Data.PsObject.Properties.Name | Select-Object -Unique
136140
#endRegion account
137141

138142
#region Verify account reference
@@ -212,6 +216,10 @@ try {
212216
if ($actionContext.Configuration.deleteAccount -eq $true) {
213217
$actionAccount = "Delete"
214218
}
219+
elseif ($actionContext.Data -eq $null){
220+
Write-Warning "Connector is configured to skip account deletion on revoke. Only updates will be made. But since no fields are mapped for the delete event, nothing will happen."
221+
$actionAccount = "NoChanges"
222+
}
215223
else {
216224
$actionMessage = "comparing current account to mapped properties"
217225

0 commit comments

Comments
 (0)