Set-UDElement on Checked attribute?

Hello,

I try to set the Checked attribute on a checkbox but it doesn’t work.
If I make a choice in the Select, the OnChange event is triggered and the switch works properly but the checkboxes are never updated …

Any idea ?

Here is my script :

New-UDCheckBox -Id "Intranet" -Label $Cache:ADGroupIntranet.Name -Checked -OnChange { }
New-UDCheckBox -Id "IwsUsers" -Label $Cache:ADGroupIWSUsers.Name -Checked -OnChange { }
New-UDSelect -Id "EmployeeIDSelect" -Label "Utilisateur" -Option {
	New-UDSelectOption -Name "sans matricule connu" -Value "NEWMAT"
	New-UDSelectOption -Name "avec matricule" -Value "Saisir le matricule"
	New-UDSelectOption -Name "externe" -Value "EXTERN"
} -OnChange  {
	switch ((Get-UDElement -Id "EmployeeIDSelect").Attributes["value"]) {
		"NEWMAT" { 
			Remove-UDElement -Id "EmployeeID"											
			Set-UDElement -Id "Intranet" -Attributes @{
				checked = $true
			}
			Set-UDElement -Id "IwsUsers" -Attributes @{
				checked = $true
			}
		}
		"EXTERN" { 
			Remove-UDElement -Id "EmployeeID"
			Set-UDElement -Id "Intranet" -Attributes @{
				checked = $false
			}
			Set-UDElement -Id "IwsUsers" -Attributes @{
				checked = $false
			}
		}
		Default { 
			Add-UDElement -ParentId "EmployeeIDColumn" -Content {
				New-UDTextbox -Id "EmployeeID" -Placeholder "Matricule"
			}
			Set-UDElement -Id "Intranet" -Attributes @{
				checked = $true
			}
			Set-UDElement -Id "IwsUsers" -Attributes @{
				checked = $true
			}
		}
	}								
}

Hi @bryce426!

Doesn’t look like New-UDCheckbox has implemented “Set-UDElement” functionality as of now.

Could you post an enhancement request on github regarding this, and i’ll look into it.


Might also add that it’s not implemented on New-UDSelect either, note that in the issue aswell :slight_smile:
2 Likes

Issue opened.

https://github.com/ironmansoftware/universal-dashboard/issues/1368

Thank you for your work.

1 Like