Hello everyone, I am running into an issue with creating a Calculated Property on an Object and then viewing the value of that property in my dashboard with Get-UDElement. Here is the code,
Creating Calculated Property (Get-DHCPScopes.ps1)
#'Selection' property value. Will be incremented based on the number of printers returned Get
$i = @{value = 0}
#Obtain all DHCP Scopes on DHCP Server.
$Object = Get-DhcpServerv4Scope -ComputerName 'DHCP Server' | Select-Object *, @{ Name = 'SelectionId'; Expression = { (value = $i.value++) }
#Return
$Object
Error
Error rendering component (dynamic)
TypeError: Cannot create property ‘__version’ on number ‘0’
All I have been able to figure out is that this has something to do with Primitive Data, but I am not sure how to resolve this. Any insight would be greatly appreciated. Thank you!
When I try this new one I get a selectionId Attribute on the objects, but it is empty as this scriptblock doesn’t return a value to the Select to set the value
... Expression = { (value = $i.value++) }
Expression = { (value = $i.value++) }
If I remove the value = and adjust it so it returns the $i.value and then increments I get a number in the data
As an alternate I removed the additional property and used scopeid instead to see a list of scopes and the id shows in the card too - we have a dashboard of DHCP Scopes, etc and use ScopeID as the selector as its unique for us and then thing we then feed into subsequent pages/calls - that may not work for you though if you need an index
Morning @TriggerAu
Thank you for your help on this! I was considering using Scope ID to be the selector, but I wanted something a bit more user friendly because I don’t always remember our IP spaces per our locations. I was able to get the code to work though as I needed to do this,
$Value then was holding the value stored in SelectionId. Kind of weird I needed to do this, but it corrected the issue and I was able to display SelectionId within the dashboard.