I have made a table based on values from AD, that our HD can use to change the office location for a user.
The UI is working as expected, but im having trouble relaying the value.
I found this example on how to retrieve values from a textbox, which is working as expected.
But when i add it to my code the Show-UDToast is just reporting that the message is empty = the Get-UDElement did not pull any of the data. Textbox - PowerShell Universal
My question is:
I want to use the SamAccountName value combined with the txtExample value, so that i can use it for setting the updated AD user value - how do i accomplish that?
Awesome!
Just discovered that if i try to change it on a user, while the entire list / table is shown, then i get the exception message.
But if i search for a user and therefor narrow it down, so that only one entry is present, then the Show-UDToast is working as expected.
When creating a table with a column that uses -Render, within that rendered content I have:
New-UDTableColumn -Property 'Actions' -Title 'Actions' -Id 'Actions'-Align center -Render {
if ($null -ne $EventData.autotask.id) {
New-UDTooltip -Id 'tooltip_serviceDetails' -Content {
New-UDButton -Icon (New-UDIcon -Icon 'info') -Variant text -OnClick {
Show-ServiceMappingModal -subscription $EventData
}
} -TooltipContent {
'Show Service Details'
}
}
else {
New-UDTooltip -Id 'tooltip_serviceDetails' -Content {
New-UDButton -Icon (New-UDIcon -Icon 'edit') -Variant text -OnClick {
Show-ServiceMappingModal -subscription $EventData
}
} -TooltipContent {
'Edit Service Details'
}
}
New-UDTooltip -Id 'tooltip_subscriptionId' -Content {
New-UDButton -Icon (New-UDIcon -Icon 'copy') -Variant text -OnClick {
Set-UDClipboard -Data $EventData.subscriptionId
Show-UDToast -Message 'Subscription Id has been copied to the clipboard!' -BackgroundColor 'LightGreen' -Position bottomRight
}
} -TooltipContent {
$EventData.SubscriptionId
}
}
The first 2 New-UDTooltip with the static TooltipContent show no issues and the New-UDButtons behave as expected, forwarding the $EventData variable as designed, for the specific table row.
The 3rd New-UDTooltip, however, uses the $EventData.SubscriptionId variable for it’s TooltipContent, but does not seem to consider the Table Row for which it should do so.
All rows shows the $EventData.subscriptionId of the first row in the table.
After playing around with this more, this seems to be working as expected. The problem is that the element IDs need to be unique. I made them unique by including the SamAccountName with the ID.
New-UDTooltip -Id ('tooltip_subscriptionId' + $EventData.SamAccountName) -Content {
New-UDButton -Icon (New-UDIcon -Icon 'copy') -Variant text -OnClick {
Set-UDClipboard -Data $EventData.subscriptionId
Show-UDToast -Message 'Subscription Id has been copied to the clipboard!' -BackgroundColor 'LightGreen' -Position bottomRight
}
} -TooltipContent {
$EventData.SamAccountName
}
The reason this is happening is because we are creating multiple buttons with the same ID when the ID isn’t unique and the last button (or tooltip) to be created is the one that ends up being registered with that ID.
That actually makes perfect sense, and when i use the old code to go to the last page in the table, the button actually works, because its the last one to get generated.
Considering a github issue was created due to this, and we were several people having the same issue / misunderstanding of this, it would be a good idea to include it in the documentation - perhaps even in the psu-demo template that we can download. I often use the examples in there, to solve issues and get inspiration - so its a win-win for everyone