Very new to ignition working on my first project. I have dropdown list in perspective. I want to configure event on mouse click, that will read the current value selected on the dropdown list and write to the tag I want. But I dont know how to read the current dropdown value? Appreciated if I can get the correct syntax.
In Perspective the selected value of the dropdown will be stored in the properties of the dropdown, specifically in “props.value”. This will equal the value corresponding to the selected label in the dropdown options. In this screenshot the selected value is “2” as is the label of the option.
Within an event script, for example on a runAction button script, one can browse the properties of other components using the property selector on the right side of the scripting window. You can drill down into the view>root>dropdown>props>value to have the property browser complete the full property path for you. In the following screenshot that would be “self.getSibling(“Dropdown”).props.value” and I store it in a variable.
This question is a little ambiguous. If you only want to bind a tag to whatever the most recent selection in a dropdown is, then @kvane 's answer will probably work for you, but there are some things to consider:
There could be multiple sessions writing to that tag, so what are you trying to gain from this? I recommend against using tags outside of controls unless you need a value which is shared across multiple sessions. The requests for help have not made it clear as to whether or not they need to use and write to the tag. If the value is specific to only this session, then you should use a session property instead of the tag.
If you want the dropdown to display the value of the tag as well as write to it, then you should use a bidirectional tag binding.
system.tag.write is deprecated, and we recommend use of the newer writeBlocking() function which expects a list of tag paths and a list of values.
The responses earlier were specifically for the Perspective visualization module.
For your case in Vision you will have a property reference selector on the right side of that script editor. If you click through the property menu you can identify your Dropdown component and select the property you want to set the tag to.
It will look something like:
event.source.parent.getComponent(‘Dropdown’).selectedValue