New-UDAutocomplete. Page not loading at all

Product: PowerShell Universal
Version: 1.4.6

Am i missing something here to make a quick autocomplete sample? Sorry completely new at this.

Hi @kevinblumenfeld,

Try to use the @(…) syntax as in the docs.

New-UDAutocomplete -OnLoadOptions {
@(‘Test’, ‘Test2’, ‘Test3’, ‘Test4’) | Where-Object { $_ -like “$Body” } | ConvertTo-Json
}

Thanks so much for your reply but I believe I have tried that. However, I don’t know what to wrap that in. What about the text input field (and new dashboard and new page?) what do I need for a super simple example that will actually load?

You don’t need the page if you are using dashboard content.

New-UDDashboard -Content {
    New-UDAutocomplete -OnLoadOptions {
     @(‘Test’, ‘Test2’, ‘Test3’, ‘Test4’) | Where-Object { $_ -like “$Body” } | ConvertTo-Json
  }
}
2 Likes

okay making progress. I didnt realize the form was self contained. just need a submit button and to learn how to pass data to a list

New-UDDashboard -Title 'PowerShell Universal' -Content {
    New-UDAutocomplete -OnLoadOptions { 
    @('Test', 'Test2', 'Test3', 'Test4') | Where-Object { $_ -like "*$Body*" } | ConvertTo-Json
} -OnChange {
    Show-UDToast $Body 
}
}

You can use a form to get the submit button going.

New-UDDashboard -Title 'PowerShell Universal' -Content {
    New-UDForm -Content {
       New-UDAutocomplete -OnLoadOptions { 
        @('Test', 'Test2', 'Test3', 'Test4') | Where-Object { $_ -like "*$Body*" } | ConvertTo-Json
       } -Id AC
       New-UDCheckbox -Id 'CB'
    } -OnSubmit {
       Show-UDToast "I'm your autocomplete value! $($EventData.AC)"
       Show-UDToast "I'm your checkbox value! $($EventData.CB)"
   }

}

Thanks @adam for helping me out :slight_smile: