Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json values in New-UDAutocompleteOption #4188

Open
bjompen opened this issue Jan 2, 2025 · 0 comments
Open

Json values in New-UDAutocompleteOption #4188

bjompen opened this issue Jan 2, 2025 · 0 comments
Labels
bug Something isn't working PowerShell Universal Issue relates to PowerShell Universal. requires triage Issue has not yet been verified by the development team. v5 Version 5 issue.

Comments

@bjompen
Copy link

bjompen commented Jan 2, 2025

Description of Issue

https://forums.ironmansoftware.com/t/json-object-oddities-with-new-udautocompleteoption/11385

I have a function that fetches data, and constructs a dropdown using New-UDAutocompleteOption, however, if the -Value parameter contains json it throws an error.

The following code works as expected (_notice the underscore in the ConvertTo-Json string):

New-UDApp -Content { 
    Function Get-STBEntries {
        [CmdletBinding()]
        param()
    
        '[{
        "Status":  "Status1",
        "Serialnr":  "aaa111"
        },
        {
        "Status":  "Status2",
        "Serialnr":  "bbb222"
        }]' | ConvertFrom-Json
    }
    
    $STBEntries = Get-STBEntries
    
    New-UDCard -Title 'Select computer' -Content {
        $STCompOptions = $STBEntries | Foreach-Object {
            [string]$Value = "_$($_ | ConvertTo-Json -Compress)"
            New-UDAutocompleteOption -Name $_.Status -Value $Value
        }
    
        New-UDAutocomplete -Label 'Select' -Options $STCompOptions -OnChange {
            Show-UDToast $EventData -Duration 100000
        } -FullWidth
    }
}

image

If i remove the underscore and do [string]$Value = "$($_ | ConvertTo-Json -Compress)" i get an error instead.

image

As there are obvious and simple workarounds for now I prioritize this as low, but it seems to me this would be an unexpected behaviour..

Version

5.0.7 - 5.1.2

Severity

Low

Hosting Method

IIS

Operating System

Windows

Database

SQLite

Licensed

Yes

Features

No response

Additional Environment data

No response

Screenshots/Animations

No response

@bjompen bjompen added bug Something isn't working PowerShell Universal Issue relates to PowerShell Universal. requires triage Issue has not yet been verified by the development team. v5 Version 5 issue. labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PowerShell Universal Issue relates to PowerShell Universal. requires triage Issue has not yet been verified by the development team. v5 Version 5 issue.
Projects
None yet
Development

No branches or pull requests

1 participant