Unable to refresh data

Hello all,

I have a function that runs some queries on a database and returns the data on a grid, so far so good.

However, when I try to run a different query that includes a different set of columns, then somehow the data does not update correctly. The strange thing is If I hit refresh, then data will appear correctly.

Here is a example:

Get-Report -Date “Last Year” -ReportType “Report 1” Should return -> Cat | Number

Cat Number
N/A 549

Get-Report -Date “Last Year” -ReportType “Report 2” Should return -> Cat2 | Number

Cat Number

Here is a snippet from the dashboard:

New-UDTabContainer -Tabs {
    New-UDTab -Text "Period" -Content {
        New-UDInput -Title " " -Id "Form" -Content {
            New-UDInputField -Type select -Name "Period"      -Values @($Period)
            New-UDInputField -Type select -Name 'ReportType'  -Values @($ReportType)
            New-UDInputField -Type select -Name 'Departments' -Values @($Departments)
        } -Endpoint {
            param($Period, $ReportType, $Departments)
                $creds = @{
                    TypeName     = 'System.Management.Automation.PSCredential'
                    ArgumentList = "user", $Password
                $params = @{
                    Server      = 'xxx.xxx.xxx.xxx'
                    Database    = 'db'
                    Period      = $Period
                    ReportType  = $ReportType
                    UserName    = 'user'
                    Credentials = New-Object @creds
                $Session:Results     = Get-Report @params
                Sync-UDElement -Id "PieChart"
                Sync-UDElement -Id "ResultGrid"
        } -ArgumentList $Period, $ReportType, $Departments
    } -Stacked -Dynamic

I am also using a UDchart which has no problem whatsoever.

Hello @b17u53r and welcome to the UD forums. On iPhone :iphone: at the moment so cannot run code but looking what you posted do you get the same results if you add the -autoreload parameter to the grid script block got a feeling that will fix it


The AutoRefresh and RefreshInterval are already set.

ok if there set thats a good thing, the chart works but not the grid…so you mentioned you changing the columns in the grid, I take it you are setting those dynamically…? You could just for debugging purposes add a new-udinputaction and put a toast of the parameters being passed, just so you know the data being passed is good…but you say pressing the F5 then gives you the correct results…are you able to reveal more of your code? Just to confirm you only have one grid with one id?

Also just thought I have had problems in the past, then I ended up naming the COLUMN I was nesting my GRID in and sync the COLUMN ID and this refreshed the whole grid, and solved my personal issue

No. Not dynamically.

Yes. I have already done that.

Yes. One grid with one id

$gridparams = @{
                        Id = "ResultGrid"
                        DefaultSortColumn = 'Issues'
                        DefaultSortDescending = $true
                        NoExport = $true
                        Title = 'Results'

                New-UDGrid @gridparams -Endpoint {
                     if ("Dep" -eq $Session:Departments -and $Session:ReportType -eq "Cat1") {
                        $Session:Results | Select-Object 'Cat', 'Number' |
                } -AutoRefresh -RefreshInterval 1

I got an example here of how I did a sync with a lot of objects:-

not seeing the -id parameter on the new-udgrid as mentioned I have in the past had to do something like:-

New-UDColumn -Size 12 -Endpoint {
    New-UDElement -Id GridData3 -Tag div -Endpoint {
        if (-not($Session:Selected -eq $null)) {
            New-UDGrid -Headers @("HEADERS", "GO", "HERE") -Properties @("HEADERS", "GO", "HERE") -PageSize 10 -DefaultSortColumn "AccountAnalysisCode" -Endpoint {
$Query3 = @"
WHERE TransactionType = 'Invoice' AND AccountAnalysisCode IN ($($Session:Selected))
AND TransactionDate BETWEEN '$($Session:Start)' AND '$($Session:End)'
ORDER BY AccountAnalysisCode,CustomerCode
                $A3 = Invoke-Sqlcmd2 -ServerInstance SQL-Server -Database YourDataBase -Query $Query3 -Username USERNAME -Password PASSWORD -QueryTimeout 500
                $A3 | Select-Object "X", "Y", "Z" | Out-UDGridData

            } -Id InsideGrid3

    } -AutoRefresh

I have updated my post with the parameters.

I understand the concept.

I just thought it would be more manageable if I could call the queries directly from the function.

After further debugging I have concluded that this must be a bug. The data is there, but I have to manually refresh the page.

@adam can you check this out?

Please file an issue if you believe this to be a bug. Much easier to track. Thanks!!

I have created an issue.