Product: PowerShell Universal
Version: 4.2.21
Test code here
$Navigation = @(
New-UDListItem -Label "All" -href '/home'
New-UDListItem -Label "01" -Href '/home?site=01'
New-UDListItem -Label "02" -Href '/home?site=02'
New-UDListItem -Label "03" -Href '/home?site=03'
)
New-UDApp -Title "component test dash" -NavigationLayout Permanent -Navigation $Navigation -Content {
new-udbutton -text "click" -OnClick {
show-udtoast -message "$($query["site"])"
$query["site"] | out-file C:\Temp\site.txt -append
}
}
When first going to the root /home page $query is empty, as expected, but when clicking on one of the navigation options the URL updates, but $query does not.
If I load the page with the site specified in the URL (/home?site=01) it works, but when switching to a different page from the navigation (/home?site=02) it doesn’t update $query, stays at what the page loaded as.
I feel like this is new. The page worked fine previously, can’t remember the version of Universal it was built on though. Could be related to this?
opened 12:57AM - 12 Apr 24 UTC
closed 12:57PM - 15 Apr 24 UTC
bug
PowerShell Universal
support ticket
P4 - low
content
Area-Apps
Size - S
### Version
4.2.17
### Severity
Low
### Environment
msi
### Steps to Repro… duce
Using a variable form a URI query used to create a variable of the same name before this behaviour was changed in 3.9.16 to address the inherent injection vulnerability of the old functionality.
However, the new `$Query` hashtable does not appear to have the same global scope the previous funcitonality offered. For example, an `-OnValidate` scriptblock of `New-UDForm` returns `null` if the hashtable is referenced. This may also be true for other scriptblocks (I haven't tested it to completion).
This code can demonstrate the issue - even if you use the `?Test=valid` in the URI, validation fails as the variable evaluates to `$null`.
```
New-UDApp -Title 'PSUTest' -Pages @(
New-UDPage -Name 'home' -Content {
New-UDForm -Id 'TestForm' -OnValidate {
if ($Query.Test -eq 'Valid') {
New-UDValidationResult -Valid
}
else {
New-UDValidationResult -ValidationError "`"$($Query.Test)`" is not valid."
}
} -OnSubmit {
Show-UDToast -Message "Success!"
} -Children {
New-UDCheckBox -Label "This is a test form"
}
}
)
```
### Expected behavior
```console
In the above example, the form should pass validation.
```
### Actual behavior
```console
The form fails validation as $Query -eq $null within the OnValidate scriptblock.
```
### Additional Environment data
(With URI of /home?Test=Valid)
New-UDApp -Title 'PSUTest' -Pages @(
New-UDPage -Name 'home' -Content {
New-UDForm -Id 'TestForm' -OnValidate {
if ($Query.Test -ne 'Valid') {
New-UDValidationResult -ValidationError "`"$($Query.Test)`" is not valid."
}
} -OnSubmit {
Show-UDToast -Message "Success!"
} -Children {
New-UDCheckBox -Label "This is a test form"
}
}
)
### Screenshots/Animations
_No response_
Product: PowerShell Universal
Version: 4.2.7
Greetings,
I’m working on an app to pull information from various APIs for a single workstation. I want to be able to pass the workstation name into the UD app via URL using the "?workstationname=WORKSTATIONNAME" query. If the query was used I’d like it to populate the textbox with the machine name that was passed in and automatically execute the contents of the button’s -OnClick scriptblock. I’d also like the page to be able to be used manually whe…
I also believe this is new because I experienced the same thing. Once I added the full URL it started working again.
from:
New-UDListItem -Label $item.label -Href "/home?license=$($item.file)" -SubTitle $item.Subtitle
to:
New-UDListItem -Label $item.label -Href "$homeurl/home?license=$($item.file)" -SubTitle $item.Subtitle
$homeurl depends on dev or production server, so now I have to check this where I didn’t prior. I believe this happened when I upgraded to 4.2.20.
4.2.20 seemed to be when it happened to me as well. I don’t recall what version I was on prior to that. I feel like it was .16 or .17 though
I switched to this, using the built in $appfullurl variable, and still have the same issue.
$Navigation = @(
New-UDListItem -Label "All" -href "$appfullurl/home"
New-UDListItem -Label "01" -Href "$appfullurl/home?site=01"
New-UDListItem -Label "02" -Href "$appfullurl/home?site=02"
New-UDListItem -Label "03" -Href "$appfullurl/home?site=03"
)
New-UDApp -Title "component test dash" -NavigationLayout Permanent -Navigation $Navigation -Content {
new-udbutton -text "click" -OnClick {
show-udtoast -message "$($query["site"])"
$query["site"] | out-file C:\Temp\site.txt -append
}
}
switching out $appfullurl with a variable made in page for the base URL and that seems to work.
$url = "https://universal.domain.local/comptest"
$Navigation = @(
New-UDListItem -Label "All" -href "$url/home"
New-UDListItem -Label "01" -Href "$url/home?site=01"
New-UDListItem -Label "02" -Href "$url/home?site=02"
New-UDListItem -Label "03" -Href "$url/home?site=03"
)
New-UDApp -Title "component test dash" -NavigationLayout Permanent -Navigation $Navigation -Content {
new-udbutton -text "click" -OnClick {
show-udtoast -message "$($query["site"])"
$query["site"] | out-file C:\Temp\site.txt -append
}
}
Looks like there are two issues I found. The query parameter not working correctly, and $appfullURL not working. Unless $appfullURL is only good on the built in docs page where I found it.
I do not believe $AppFullUrl and other system variables are available except under app context, e.g. available inside New-UDApp.