Update <input value> in UI-template node only if inputting payload/topic are specific

Im using a UI-template-node to create a few textfields and a button to store the user-input from the text field in my flow variables. By clicking on the button all values in the textfield are set to "". Now since I didnt want to include the whole logic of the tab into one template I seperated the check for valid input in an extra function-node. When the user input is wrong I'm sending a msg to the ui-template node (topic="check", payload="false").

Is there a way to update the value of the textfields to the flow-variables whenever a msg with topic="check" and payload="false" arrives? That way the user can correct the textfields that have wrong input and wont have to fill in all textfields again.

Heres the code im using for one of the textfields and the button

<md-input-container>
  <label>Number</label>
  <input type="number" 
  id="order"
  ng-model="user.order" 
  placeholder="10-digits" 
  ng-change="msg.payload = user.order; msg.topic = 'order'; send(msg)" 
  style="color: black;" 
  onKeyPress="if(this.value.length==10) return false;">
</md-input-container>

<md-button 
onclick=" document.getElementById('order').value = '';"
ng-click="msg.payload = 'true'; msg.topic = 'check'; send(msg)"
style="
    background-color: #72b904;
    font-size: 15px;
    line-height: 50px;">
    send
</md-button>

I got to the point where I added a script to my template which can act on a new msg.payload:

<script>
    (function(scope) {
        scope.$watch('msg.topic', function(topic) {
            if (topic === 0) {
                document.getElementById('order').value = flow.get(msg.socketid).order;
                }
        });
    })(scope);
</script>

The only problem left seems to be how to fetch the data from the flow context. The data is stored as following (the values are from a test i just did):
{"date":"2023-03-24T13:26:55", "order" :123}

If anybody knows how to insert the value of the flow variable into the elementbyId.value would be massive help. Otherwise i guess the workaround would be to put the flow-values into the msg before passing it into the template

It is not a workaround but the only way to do it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.