Dynamically disable a select

I am working on a Form for a customer that has a number of dynamic aspects. I have half a dozen select elements that all change values based on the previous choice, and this is working well. I was asked if, based on the choice from an earlier select field (Operating System), we could disable several other select fields. I’ve tried a couple of different ways, such as this:

        New-UDSelect -Label "OS" -Id "OS" -Option {
        foreach ($item in $aFields) {
            if (!([string]::IsNullOrEmpty($item.OS))) {
                New-UDSelectOption -Name "$($item.OS)" -Value "$($item.OS)"
            }
        }             
    } -OnChange {
        Set-UDElement -Id "Drive2Letters" -Disabled
    }

I also tried something like this:

        } -OnChange {
        Set-UDElement -Id "Drive2Letters" -Properties @{Disabled = $true}
       }

But I just don’t seem to be hitting the syntax correctly. Has anyone successfully done this before?

Product: PowerShell Universal
Version: 1.5.8

Hi @JLogan3o13 You don’t seem to be calling set-udelement correctly. You need to use it like
I show here:- Documentation Questions - #5 by psDevUK
And you are trying to set the state to disabled…is this an option? I know hidden used to exist…I mention in this post Update Table with Set-UDElement - #4 by psDevUK how you can find the values held in the STATE. I hope this helps :slight_smile:

Thanks for the response, I will look at the first link. As for the second, I use ChroPath, since this customer does not allow FF on the network, and it gives me the same info. Disabled is indeed an option, and is also shown in the list of available parameters in the docs. I can manually set a select to -Disabled, just need to find the right syntax to flip that flag based on outside data. Thanks again.

1 Like