I have a component with a custom property bound to a tag.
When the component is clicked on, I want to script it such that I can get the tag from event.source.myCustomProperty
and use it in a function such as system.tag.writeBlocking()
which requires a string tag path.
If I do system.tag.writeBlocking(event.source.myCustomProperty, stuffToWrite)
it doesn't work, I believe because I need to convert the tag that is given by event.source.myCustomProperty
to a string.
I feel like this boils down to converting a tag to a string. How to do this?
Is .myCustomProperty
bound to a tag so it gets the tag value?
If so, then no, there's no documented way to get its tag path. (There is undocumented, non-trivial use of the window's InteractionController
to do so, but you are on your own.)
Typically, if you expect to need the path for a tag that you are going to bind, you should plan on placing that tag path string in a window parameter or template parameter, and using indirect tag binding where you need the tag value. Then anywhere you need the string for other reasons, you can get it from the parameter.
1 Like
Yes, bound to a tag to get tag value, such as {[default]_tagDir/tag}.
Your suggestion is essentially what my work around does. I just felt like there had to be a better way.
Using tag path string parameters throughout your projects is crucial to producing re-usable UI assemblies, whether formally as templates or not.
This is the better way.