Rendered table buttons not working with if statements

Product: PowerShell Universal
Version: 4.2.21

Hi I have created a page to look up group memberships with the ability to add and remove users to the group. Adding users works but removing them doesn’t. During my testing it seems like clicking the remove button does absolutely nothing as it doesn’t even seem to process either IF statement

Context: The rest method stored in $Page:Output will contain the following properties
DistinguishedName
Name
SAMAccountName
ObjectClass
Note

New-UDRow -Columns {
    New-UDTextbox -id 'GroupMembershipTextbox' -Label 'Enter the group name'
    New-UDSelect -Label 'Domain' -Id 'QF_selectDomain' -Option {
        foreach ($domain in $Domains) {
            New-UDSelectOption -Name $domain -Value $domain
        }
    } -OnChange {
       $Page:ARGP_DomainSelection = $EventData
    }
    New-UDButton -Text 'Search' -OnClick {
        Sync-UDElement 'GroupMembershipDynamic'
    }
}
New-UDRow {
    New-UDDynamic -id 'GroupMembershipDynamic' -Content {
        IF((Get-UDelement 'GroupMembershipTextbox').value -notlike $null) {
            $groupname = (Get-UDElement -id 'GroupMembershipTextbox').value
            IF ($Page:ARGP_DomainSelection -like 'Domain1') {
                $Page:Output = Invoke-RestMethod "http://uda1spsu001:5463/OnPrem/ADGroupInfo/$($groupname)?domain=Domain1" -Method Get
            } elseif ($Page:ARGP_DomainSelection -like 'Domain2') {
                $Page:Output = Invoke-RestMethod "https://uda1spsu001:5463/OnPrem/ADGroupInfo/$($groupname)?domain=Domain2" -Method Get
            }
            If ($Page:Output.note[0] -notlike $null) {
                New-UDPaper -Children {
                    New-UDIcon -Icon 'warning' -Color 'red' -Size md
                    New-UDTypography -Text "   "
                    New-UDTypography -Text $($page:Output.note[0])
                }
            }
            $Page:Columns = @(
                New-UDTableColumn -Property distinguishedname -Title "Remove" -Render {
                    New-UDButton -id "button$($EventData.distinguishedname)" -Text "Remove" -ShowLoading -LoadingIndicator (New-UDSpinner -tagName PongSpinner -color '#0d75ba' -Size 30) -OnClick {
                        IF ($Page:ARGP_DomainSelection -like 'Domain1') {
                            Remove-ADGroupMember -Identity (Get-UDelement 'GroupMembershipTextbox').value -Members $EventData.distinguishedname -Server $Domain1DC
                        } elseif ($Page:ARGP_DomainSelection -like 'Domain2')  {
                            Remove-ADGroupMember -Identity (Get-UDelement 'GroupMembershipTextbox').value -Members $EventData.distinguishedname -Server $Domain2DC
                        }
                    }
                }
                New-UDTableColumn -Property Name -Title "Name" -IncludeInExport
                New-UDTableColumn -Property SamAccountName -Title "Username" -IncludeInExport
                New-UDTableColumn -Property objectClass -Title "Object Class" -IncludeInExport
            )
            New-UDTable -Data $Page:Output -Columns $Page:Columns -ShowPagination -Dense -PageSize 15 -ShowSearch -ShowExport
            New-UDButton -Text 'Refresh Table' -OnClick {
                Sync-UDElement -id 'GroupMembershipDynamic'
            }
            New-UDButton -Text 'Add User' -OnClick {
                Show-UDModal -Content {
                    New-UDStack -Direction column -Children {
                        New-UDTextbox -Id 'AddUserToGroup' -Label 'Username of people to add' -Multiline
                    }
                } -Footer {
                    New-UDButton -Text 'Add User' -ShowLoading -LoadingIndicator (New-UDSpinner -tagName PongSpinner -color '#0d75ba' -Size 30) -OnClick {
                        IF ($Page:ARGP_DomainSelection -like 'Domain1') {
                            ((Get-UDelement 'AddUserToGroup').value) -split "`n" | foreach {
                                Add-ADGroupMember -Identity (Get-UDelement 'GroupMembershipTextbox').value -Members $_ -Server $Domain1DC
                            }            
                        } elseif ($Page:ARGP_DomainSelection -like 'Domain2')  {
                            ((Get-UDelement 'AddUserToGroup').value) -split "`n" | foreach {
                                Add-ADGroupMember -Identity (Get-UDelement 'GroupMembershipTextbox').value -Members $_ -Server $Domain2DC
                            }
                        }
                        Show-UDToast -Message 'User(s) have been added' -TransitionIn bounceInLeft
                        Hide-UDModal
                    }
                    New-UDButton -Text 'Cancel' -OnClick {
                        Hide-UDModal
                    }
                }
            }
        }
    } 
}

@adam Are you able to provide any insight into this issue?

So I ended up finding the solution. For future reference and potential future documentation the issue was that the buttons didn’t like having their ID set as the users DistinguishedName (Too long or contained certain characters?).

The resolution was just to render the buttons with the id of the users SAMAccountName; which in my case only contains upper and lowercase alphanumeric characters as well as ’ - ’