Focusing input back to input box

Hey folks,

I’m trying to use UD to help us decommission a bunch of devices, by scanning their asset tag. I’d like to refocus on the text field it gets input, but I’m unable to make this work. Here’s the relevant section of code:

New-UDInput -Id ENTRY -Title "Asset Retirement" -Endpoint {
    param(
        [ValidatePattern('[Aa]\d{6}')]
        $AssetID)         
     
    $Session:Asset = Get-WHDAsset -QualifierString "(assetNumber caseInsensitiveLike '$AssetID')"
    $Session:Asset = Get-WHDAsset -AssetId $Session:Asset.id
    $Session:Asset | Add-Member -NotePropertyName "Processed" -NotePropertyValue "False"
    
    $NewAssetList = @()
    $Cache:AssetList | ForEach-Object {
        $NewAssetList = $NewAssetList + $_
    }
    $NewAssetList = $NewAssetList + $Session:Asset
    $Cache:AssetList = $NewAssetList

    New-UDInputAction -ClearInput
    New-UDInputAction -Content{
        Select-UDElement -ID 'ENTRY'
    }
}

I’ve tried variations of the New-UDInputAction block. “-ClearInput -Content {}” doesn’t seem to do either, and separate, just clears input. The previous thread I could find on this indicates that maybe this isn’t implemented yet - if so, is there a different way I can go about this?

Hi @corrionc
Try using Select-UDElement to change the focus.
Select-UDElement -Id “AssetId”

Hey @BoSen29,

No luck. When I add either:
Select-UDElement -id 'AssetID' or
New-UDInputAction -ClearInput -Content {Select-UDElement -id 'AssetID'}

to the endpoint body, it doesn’t refocus. I get this error in Chrome’s dev console:

ud-dashboard.jsx:112 Uncaught TypeError: Cannot read property 'focus' of null at HubConnection.<anonymous> (ud-dashboard.jsx:112) at HubConnection.js:438 at Array.forEach (<anonymous>) at HubConnection.push.HubConnection.invokeClientMethod (HubConnection.js:438) at HubConnection.push.HubConnection.processIncomingData (HubConnection.js:333) at WebSocketTransport.HubConnection.connection.onreceive (HubConnection.js:65) at WebSocket.webSocket.onmessage (WebSocketTransport.js:107)