Please help me know how to update a tag from textfield value.
I tried checking bidirectional box hoping that when I clicked in a field, made an edit, then clicked or tabbed out that it would update the tag. It doesn’t it goes back to the original value.
I know this is a silly question, because I have scripted this exact thing in the past. I just cannot find my scripts or projects and I cannot find any examples of updating a tag from the client event or script on the IA site.
Thank you. Please link me if this is a duplicate… I couldn’t find it in the search.
I found this… but no code snippets yet…
Is this what I am looking for? How to I use this? Auto change would be nice, but submitting all changes at once with a button is also needed. I see ways to script everything but writing back to the tags/device.
You shouldn’t need to do anything so fancy; A bidirectional binding should absolutely be enough and should be working. I was able to set up such a bi-directional Tag/Text Field combo in just a few seconds without issue.
Could you provide a screenshot of your binding, along with the path of your tag?
That looks correct.
To continue looking into this I’ll need a couple of things:
A single screenshot which shows the Text Field and the binding dialog side by side, with a different value in the Text Field than is displayed in the binding dialog.
A copy of the View in question via Direct Message.
What exact type of tag is being used here? It looks like this a String Array Tag, but I’d like to be sure.
It is a StringArray.
The Text Field data is populated by the tag value.
I wanted to change the tag value by updating the text field.
This works well in the vision module with:
value = event.source.parent.getComponent('Text Field').text
system.tag.write('[default]OPC_Nano1/SomeObject/Contents[0]', value)
You shouldn’t do this with a script. Your bi-directional binding should be enough; this is why I requested a screenshot which shows a differing value in the text from what the binding dialog shows you.
Provided nothing else than you have configured a bi-directional binding on TextField.props.text- as you have configured in your earlier screenshot - what happens to the tag value when you change the value of TextField.props.text?
In other words, please change the value of TextField.props.text to be 88888888888049, and then please take your screenshots again and post them here.
If the underlying tag is a single precision floating point number, the change from 88888888888048 to 88888888888049 won’t register–it’s below the minimum change possible. It can’t be Int4, as that won’t hold such a large value at all.
I don’t know what that last comment means. The data type is String Array.
When I change the value of the text field, the tag is not updated. In 2.5 seconds, the text field is changed back to the original tag value(or the current tag value, since it wasn’t updated). If I move out of the text field (Unfocus), the value is immediately reset to the existing tag value.
In vision I have the same problem with bi-directional binding. In vision I am able to script the change successfully.
I really want to use perspective for more reasons than anyone wants to read on this thread. Please help.
Tag value -> OriginalText -> Defualt TextField representation -> ["OriginalText"] ->["NewText"]-> tag updated to -> "NewText"-> text updated from tag to text field-> ["\"NewText\""]
If there is a comma in the Text… well … it gets really messy.
I’m not able to replicate your issue, so I’ll have to recommend that you get in contact with our support team. Please make sure your reference this thread so that they can easily see what you’re encountering.