Hi all,
I have a table that displays a SQL agent job status, and a button that starts that job.
When the button is pressed, I want the table to refresh/update with the status returned from the SQL agent job
e.g.
$session:JobInfo = Get-SqlAgentJob -ServerInstance $cache:cfgSQLserver -Name $cache:cfgSQLJobName | Select CurrentRunStatus,...,...,...
But I don’t want to be making that request when the button hasn’t been pressed.
Is this sensible…
New-UDDynamic -Id 'randomOuter' -Content {
if($session:autoUpdate -eq $true) {
$autoRefreshSplat = @{
Autorefresh = $true
}
} else {
$autoRefreshSplat = @{
Autorefresh = $false
}
}
New-UDDynamic -Id 'randomInner' @autoRefreshSplat -Content {
$session:rand = Get-Random
New-UDTypography -Text "autoupdate=$session:autoUpdate, random number updated to=$session:rand, update occurred=$(Get-Date -f "hh:mm:ss")" -Variant 'h6'
}
}
New-UDSwitch -OnChange {
$session:autoUpdate = $Body
Sync-UDElement -Id 'randomOuter'
}
This results in…
So the above example seems to work, but is it the best way to achieve the goal? As in a way to enable/disable autorefresh on a table?
And then, how do you change the refresh interval for a New-UDDynamic? The -AutoRefresh updates every 10 seconds but I’m after every 2 seconds when the job is running. I tried “-RefreshInterval 2” but when included it results in nothing displayed.
(on UD v3.0.0, PSU v1.3.1)
Cheers,
Steve.