Product: PowerShell Universal
Version: 3.8.12
I see that Issue #2014 is similar to what I am facing. I am testing the SQL CRUD dashboard example and using pages files for various pages. I keep getting the Invoke cannot find the term New-UserEditButton and the function is in the same Page file as the UDTable that is rendering the column, so not sure what was happening until I saw the example for Issue #2014.
I have put together code that I can reproduce the issues as it turns out the render cannot find variables or function within the the pages content section.
New-UDDashboard -Title "Test" -Pages @(
New-UDPage -Name "Page 1" -Content {
$MyVar = 'Testing'
function New-ButtomCustom {
New-UDButton -Text "Click for Dessert!" -OnClick {
Show-UDToast -Message $EventData.Dessert
}
}
$Data = @(
@{Dessert = 'Frozen yoghurt'; Calories = 1; Fat = 6.0; Carbs = 24; Protein = 4.0}
@{Dessert = 'Ice cream sandwich'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
@{Dessert = 'Eclair'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
@{Dessert = 'Cupcake'; Calories = 159; Fat = 6.0; Carbs = 24; Protein = 4.0}
@{Dessert = 'Gingerbread'; Calories = 200; Fat = 6.0; Carbs = 24; Protein = 4.0}
)
$Columns = @(
New-UDTableColumn -Property Dessert -Title Dessert -Render {
Show-UDToast -Message $MyVar
New-ButtomCustom
}
New-UDTableColumn -Property Calories -Title Calories
New-UDTableColumn -Property Fat -Title Fat
New-UDTableColumn -Property Carbs -Title Carbs
New-UDTableColumn -Property Protein -Title Protein
)
New-UDTable -Columns $Columns -LoadData {
$TotalCount = $Data.Count
$Data | Out-UDTableData -Page $EventData.Page -TotalCount $TotalCount -Properties $EventData.Properties
} -Sort -Export
}
)
This code only works when the $MyVar and New-ButtomCustom function are above the Dashboard code, so is this a bug? Should I be adding all the functions and variables to the Dashboard code and not in the pages content section? Please advise