Wait for modal?

I have code which calls a function that contains a modal for user input (2 textboxes with a button). The issue is that the underlying script does not “wait” for the modal to complete and return input. The underlying code needs the information from the modal to run successfully. Is there anyway to make this work, or do I need to do a “sleep loop until not null” or some such?

Thanks

Invoke-UAScript -Id xx -AppToken $fullAppToken | Tee-Object -Variable Job | Wait-UAJob -AppToken $fullAppToken

To get the result from the modal, but I have had issues with it, if the job takes too long to produce a result (+1 min)

sorry, this is for a dashboard, not the UA stuff. This may be in the wrong place. not sure of the proper place to post a v3 powershell universal dashbaord question.

Basically, I have a modal asking for a username and password, which I am attempting to create a PS Credential object with and use later in the script for a remote connection.
The script proceeds past the modal before I have his the submit button, and not getting the credential

I think I’ve seen something similar on v2.
I had this sort of setup (just a simplified version, not working code, but so you can see the sort of logic)

new-udbutton -onclick {
    <initial code block>
    $variableA = "something"

    if($variableA -eq "something"){
      $VariableB = "something"
    }else{
      show-udmodal -endpoint {
        new-udbutton -text "YES" -onclick {$VariableB = "something"}
        new-udbutton -text "NO" -onclick {$VariableB = "something else"}
      }
    }
    <finishing code block>
}

I found that as soon as the modal opens, the finishing code block runs at the same time in parallel, i think this happens because its considered a separate endpoint.
The solution, copy the finishing code block inside both the top of my if statement, and inside the modal:

new-udbutton -onclick {
    <initial code block>
    $variableA = "something"

    if($variableA -eq "something"){
      $VariableB = "something"
      <finishing code block>
    }else{
      show-udmodal -endpoint {
        new-udbutton -text "YES" -onclick {$VariableB = "something"}
        new-udbutton -text "NO" -onclick {$VariableB = "something else"}
        <finishing code block>
      }
    }
}
1 Like