Move drop down list values to a memory tags from a template

Good Morning. I am trying to move a selected string that I have chosen from a drop down list and moved to a Text Field. All of this is inside of a template.

I want to move the value to the memory tag that coincides with the BD number of the template.

In the template, there is a Template Property “bdName” that I have used throughout the project.

On my Accept button, in the script editor there is system.tag.writeBlocking function that I cant get to work. The following error comes up when theAccept button is pressed.

Anyone doing this in a template that can provide a suggestion?



your tag you are building up in the system.tag.writeBlock isn’t quite formatted correctly.

do something like this:

['[default]Ohio MHicks/CI 19-133/Box Dumper/Material/BD' + toStr(event.source.parent.bdNum)]

Then the bdNum custom property is properly added to the tagPath

I made the modification and then got this error. Should there be something in the [value]?
I looked through the IAU for some help on this but no luck. Thank you for helping me out…

Post your raw code using the triple quotes so I can take a look at it.

I am pretty new to Ignition. I am not sure what you mean by raw code.
Everything I am using for my Accept button is in the script editor snip above.
Sorry for be so green at this :slight_smile:

Just copy your code in the actionPerformed event and post it here. It’s easier to see what you are trying to do.

when you do post it here start and end the code with ``` so it is properly formatted.

Don’t worry… everyone was new at one point.

I am using the Set Value tag tab in the Event Handler. as shown below. I am not writing any code per say. The snip below works well but it only writes to one tag. I am trying to use bdNum in place of the Highlighted 408 in the snip.

Copy the code from the script editor.

The Set Tag Value code creates that code. Since you are trying to do something a little out of the normal then we need to modify that code.

Alternatively you can create a custom property that indirectly references your desired tag and write to that.

Thats where I was trying to use bdNum in place of 408 as shown below.
It seems like it should have worked…

“”“value = event.source.parent.getComponent(‘BD Material’).text”""

“”“system.tag.writeBlocking([’[default]Ohio MHicks/CI 19-133/Box Dumper/Material/BDevent.source.parent.bdNum’], [value])”""

OK… so this is how that need to look:

value = event.source.parent.getComponent('BD Material').text

system.tag.writeBlocking(['[default]Ohio MHicks/CI 19-133/Box umper/Material/BD' + toStr(event.source.parent.bdNum)], [value])

Alternatively you can do this so see what is happening. The print will show up in the console. That way you can check the tag that is being created to make sure it looks correct.

value = event.source.parent.getComponent('BD Material').text
tagPath = '[default]Ohio MHicks/CI 19-133/Box umper/Material/BD' + toStr(event.source.parent.bdNum)
print 'tagPath: %s' %tagPath
system.tag.writeBlocking([tagPath], [value])

BTW the triple quote are these: ```

LOL. 3 apostrophes are a triple quote. Thanks…
I think that is what you suggested originally. I put it in the script Console and this is what I get

Thanks again for your time helping me…

So that won’t work in the Script Console.

What I meant was the output console of either runtime or the designer.

Copy that script into the script editor portion of your actionPerformed on your button and let me know what happens.

Uhm, toStr() is not python. That is a function used in expression bindings. In python, use str(). The error is visible in the original screenshot.

You also need to obtain bdNum from somewhere.

Here is what I had in the script console and also what the Output Console showed.

10:05:51.090 [AWT-EventQueue-0] ERROR com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter - Error executing script for event: actionPerformed
on component: Accept Button.
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
File “event:actionPerformed”, line 13, in
NameError: name ‘toStr’ is not defined

at org.python.core.Py.NameError(Py.java:290)
at org.python.core.PyFrame.getname(PyFrame.java:257)
at org.python.pycode._pyx304.f$0(<event:actionPerformed>:15)
at org.python.pycode._pyx304.call_function(<event:actionPerformed>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:761)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:187)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:278)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
at com.sun.proxy.$Proxy62.actionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Caused by: org.python.core.PyException: Traceback (most recent call last):
File “event:actionPerformed”, line 13, in
NameError: name ‘toStr’ is not defined

toStr() is not defined because it is not python. See my prior comment.

OK. I changed" toStr" to str and got the following message.
Illegal “+” Shoul dthat be eliminated?

Oh man. I’ve not had enough coffee @pturmel
OK… sorry.

get rid of everyting in that sript block and put this in

 value = event.source.parent.getComponent('BD Material').text

system.tag.writeBlocking(['[default]Ohio MHicks/CI 19-133/Box Dumper/Material/BD' + str(event.source.parent.bdNum)], [value])
1 Like

You guys are awesome!!! That worked. I hope to help others out like this someday…
Thanks again!!!

Not a problem. Sorry about all the confusion. Need more coffee.

Good luck!