Using builtin variables in pages

In Powershell Universal (v4), we have built pages with forms that asks users for input and then using these to automate stuff.
I have found that these pages are defined as .xml files in the file system, but we would (for example) like to pre-populate a textbox with the user email or username, using the builtin variable $UAJob.Identity.Name. As I understand it, we can’t use this in the xml file?
If not, how do we define a more dynamic page? I have seen references to cmdlets like New-UDPage, but not sure where to put these so that they show up in Powershell Universal?

Manually create a page using New-UDPage.


New-UDPage -Blank -Name "TestPage" -Title "My Test Page" -HideNavigation -id "TestPage"  -Content {
      #My UD commands here...

Which ever page is your main home page add the -DefaultHomePage parameter to that pages New-UDPage cmdlet:

New-UDPage -Name "Home" -Blank -DefaultHomePage -Title "My app" -id "HomePage"  -Content {
   #my homepage here

Store these pages in a file in a folder somewhere in your app.

In your main file where you have your New-UDApp cmdlet load your pages into memory:

 $pages = @(
        # Load a folder of pages
        Get-ChildItem '/root/.PowerShellUniversal/Repository/dashboards/myapp/myPages*.ps1' -Recurse -File | ForEach-Object {
            & $_.FullName
       # Load a page
        & '/root/.PowerShellUniversal/Repository/dashboards/myapp/home.ps1'

in your new-udapp cmdlet you will then need to declare you pages using the -Pages parameter:

New-UDApp -Title "My App"  -Pages $pages

Hope this helps

I’ve seen those code snippets before, but where to put them? In PowerShell Universal / User Interfaces / Pages, I have a few pages, defined by xml-files located in %programdata%\UniversalAUtomation\Repository\Pages. These are not relevant here as I understand it.
I have also created an app (PowerShell Universal / User Interfaces / Apps), but code for creating for example a Form does not work, generates an error rendering dashboard in PSU. Neither does the New_UDPage examples above. But is Apps not where I’m supposed to put the code?

Apologies, just seen this post.

The New-UDPage commands can go in separate ps1 files

The $pages scriptblook and New-UDApp command go in your main dashboard/app file in that order.