Execute Function to update data

Hi I have a function. in my dashboard as below

$Cache:MigrationFileInfo = (join-path $PsscriptRoot “MigrationProjectInfo.json”)

$CacheAssessmentInfo = Get-SPAzureMigrateAssessment -MigrationInfo $Cache:MigrationFileInfo

what i need this to do is to execute the API call every time i reload the dashboard or every 5 mins. the AssessmentInfo variable is sorted and the data is displayed in multiple other elements within the dashboard. The issue am having is that the $Cache:AssessmentInfo var does not update event if i refresh the dashboard. However if I restart the Powershell Universal Service the dashboard then updates. even a stop/start from the admin dashboard does not work. not sure what am doing incorrectly I read up about dynamic regions and tried the below. but the value in $Cache:AssessmentName is null

$Cache:AssessmentName = @()

New-UDDynamic -Id 'date' -Content {
$Cache:AssessmentInfo = Get-SPAzureMigrateAssessment -MigrationInfo $Cache:MigrationFileInfo 
  foreach ($Assessment in $Cache:AssessmentInfo) {
    $AssessmentName += "$($Assessment.Name)"
  }
  $Cache:AssessmentName = $AssessmentName | Select-Object -Unique
} -AutoRefresh 300 

New-UDAutocomplete   -Options $Cache:AssessmentName -Id "Application_Name" -Label"ApplicatioName"

not sure what am doing incorrectly.

TIA