GUID not unique to each tab in Browser using New-UDDynamic

Product: PowerShell Universal
Version: 3.3.7

In my dashboad i generate a GUID

$session:ApplicationRequestGUID = [guid]::NewGuid()
                $ApplicationRequest = New-Object –TypeName PSObject –Prop ([ordered]@{
                    guid            = $session:ApplicationRequestGUID 
                    ApplicationName = $Session:ApplicationtoManage.ApplicationName

                    $Session:InvokeResult = Invoke-PSUScript -name 'SubmitApplicationRequest.ps1' -integrated -ApplicationRequest $ApplicationRequest 
                    $LogPath = 'C:\temp\logs\ApplicationRequest\'

$LogFileName = "$($ApplicationRequest.guid).log"
$LogFullFileName = $LogPath + $LogFileName

New-UDCard -id 'Bob' -Content {
New-UDDynamic -Content {
                     $Session:ResultfileContent = get-content -path $LogFullFileName -ErrorAction SilentlyContinue
                    if ($Session:ResultfileContent)
                        New-UDAlert -Text "$(get-Date)" 
                        New-UDAlert -Text " GUID:$session:ApplicationRequestGUID"
                        New-UDAlert -Text "Job Started!"
                        foreach ($Session:Line in $Session:ResultfileContent )
                        New-UDAlert -Text "$Session:Line"  
                        New-UDAlert -Text "$(get-Date)"
                        New-UDAlert -Text "Waiting for job to start"

                    } -AutoRefresh -AutoRefreshInterval 5

The problem is if I have multiple tabs open the GUID last generated is use by all tabs in my browser on refresh of the ud dynamic element

Tab1 = page is loaded with a GUID of 1 and the guid is displayed in a uddynamic element with auto refresh

Tab2 is opened and loads with a GUID of 2

Tab 1 is refreshed and uddynamic element updates with a GUID of 2

I have tried

New-UDDynamic -id “GUID:$session:ApplicationRequestGUID”

but that makes no difference.

What am i doing wrong?

TLDR, you need to make your variables unique to the page.

Basically what you are doing is you are rewriting the $session:ApplicationRequestGUID each time you open a new tab. This is because the $Session: scope is available between runspaces and is tied to your session with the dashboard. So you need to make that page “unique” in some way. You can pass a variable to the page to give it an assigned and unique value. That way you can create an entry in the hashtable to contain your variables.

awesome, thanks for the pointer, I thought I was doing that using session variable :slight_smile: :thinking: