# Tag value change script help

**URL:** <https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [August 11, 2022, 9:00pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939 "2022-08-11T21:00:23Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 11, 2022, 9:00pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/1 "2022-08-11T21:00:23Z")

</div>

Hello, I have 8 mutli state buttons and 8 drop downs working of a dataset for each. I need to make sure none of the 8 can have the same value at the same time.

I was thinking a value change script on the tag would be best.

I’m feel a little lost on the best way to script it. Below is my code, any input would be appreciated. Essentially adding values to array, and cross checking. if already in use write old value i.e. no change else, change to new value on selected tag . Do I need the else?

```auto
# create array to hold current values
MSBchecks = []
# add tag valyes to array
tags = system.tag.browseTags(parentPath="System1/Project1/Filler Supply Screen/PumpAndValve/Pump", recursive = True)
for tag in tags:
    # Wrties tag path to array
    MSBchecks.append (tag.value)
# checks if current value is already in use
if currentValue.value in MSBchecks:
    if not 0:
        message = "device " + currentValue.value + "is already being used. please unselect it and try again "
        system.tag.write("Tanks/tankHiSP/selection5",previousValue.value)
	    system.gui.messageBox(message, "Pump Error")
else:
    system.tag.write("Tanks/tankHiSP/selection5",currentValue.value)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 11, 2022, 11:45pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/2 "2022-08-11T23:45:01Z")

</div>

I wouldn’t use tags at all. I’d use my `view()` function to filter the master list of choices at each dropdown to exclude the choices in the others. Like this, for the 3rd dropdown:

```auto
view("Select * Where value not in args",
  {Root Container.path.to.master.data},
  {Root Container.Dropdown 1.selectedValue},
  {Root Container.Dropdown 2.selectedValue},
  {Root Container.Dropdown 4.selectedValue},
  {Root Container.Dropdown 5.selectedValue},
  {Root Container.Dropdown 6.selectedValue},
  {Root Container.Dropdown 7.selectedValue},
  {Root Container.Dropdown 8.selectedValue})

```

Notice how I skipped `Dropdown 3`. Do likewise for the others.

No script. Just the above binding on the choices data for each dropdown.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 12, 2022, 10:41pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/3 "2022-08-12T22:41:55Z")

</div>

> [@pturmel](#):
>
> ` {Root Container.path.to.master.data},`

@pturmel can you please explain this line a little more?

Thank you!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 13, 2022, 11:25am UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/4 "2022-08-13T11:25:28Z")

</div>

The view function’s first argument after the string is the FROM dataset. In this case, it would be a static dataset on a custom property (Root Container, probably) contain all of the possible choices.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 14, 2022, 1:08pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/5 "2022-08-14T13:08:55Z")

</div>

@pturmel While this looks perfect. I’m having trouble finding documentation for the `view()` function. Would you be able to point me in the right direction? This is for my own benefit so I can find similar things in the future.

Thank you!

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 14, 2022, 1:35pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/6 "2022-08-14T13:35:30Z")

</div>

The `view()` function is part of @pturmel’s simulation aids module. Which is free. Although I’m not sure if it supports 7.8.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 14, 2022, 1:37pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/7 "2022-08-14T13:37:09Z")

</div>

There is a version for v7.8 still available, but I don’t actively support it. See all options (with link to docs) here:

[https://www.automation-pros.com/modulesales.html](https://www.automation-pros.com/modulesales.html)

The page for the `view()` function itself is here:

[https://www.automation-pros.com/simaids/doc/expression.view.html](https://www.automation-pros.com/simaids/doc/expression.view.html)

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 14, 2022, 2:07pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/8 "2022-08-14T14:07:06Z")

</div>

Well I guess here’s to hoping I don’t run into issues, or I’ll have to script it an alternate way.

Thankfully from what I hear they are gonna upgrade us next year.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 15, 2022, 2:34pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/9 "2022-08-15T14:34:26Z")

</div>

@pturmel that’s perfect for the drop down. Would the multistate button be able to work in a similar way.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 15, 2022, 2:35pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/10 "2022-08-15T14:35:47Z")

</div>

You’ll have to explain what you’re after for those (I don’t use them).

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 15, 2022, 2:49pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/11 "2022-08-15T14:49:05Z")

</div>

Essentially same thing. User can’t select button state if already selected on other button.

But honestly at this point I’m tempted to make it all dropdowns now.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 15, 2022, 9:48pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/12 "2022-08-15T21:48:54Z")

</div>

@pturmel I’d like selected value 0 to be exempt because that is the default none selection. How would I go about writing that?

would something like `Select * Where value not in args and value not 0`  
Thank you

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 15, 2022, 10:18pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/13 "2022-08-15T22:18:55Z")

</div>

```auto
Select * Where value == 0 or value not in args

```

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 17, 2022, 2:44pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/14 "2022-08-17T14:44:15Z")

</div>

@pturmel I’m getting this error:

```auto
java.lang.Exception: Error executing expression binding on
Filler Pump Popup Update.Root Container.Group.Dropdown 8.data
	at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:91)
	at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.startup(ExpressionPropertyAdapter.java:112)
	at com.inductiveautomation.factorypmi.application.binding.DefaultInteractionController.setPropertyAdapter(DefaultInteractionController.java:203)
	at com.inductiveautomation.factorypmi.designer.property.configurators.ExpressionConfigurator.bind(ExpressionConfigurator.java:283)
	at com.inductiveautomation.factorypmi.designer.property.configurators.ExpressionConfigurator.tryCommit(ExpressionConfigurator.java:219)
	at com.inductiveautomation.factorypmi.designer.property.configurators.ConfiguratorMultiplexor$EditorParent.tryCommit(ConfiguratorMultiplexor.java:213)
	at com.inductiveautomation.factorypmi.designer.property.configurators.ConfiguratorMultiplexor.tryCommit(ConfiguratorMultiplexor.java:358)
	at com.inductiveautomation.factorypmi.designer.property.configurators.DynamicOptsDialog.doOK(DynamicOptsDialog.java:117)
	at com.inductiveautomation.factorypmi.designer.property.configurators.DynamicOptsDialog.access$000(DynamicOptsDialog.java:43)
	at com.inductiveautomation.factorypmi.designer.property.configurators.DynamicOptsDialog$1.actionPerformed(DynamicOptsDialog.java:83)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.WaitDispatchSupport$2.run(Unknown Source)
	at java.awt.WaitDispatchSupport$4.run(Unknown Source)
	at java.awt.WaitDispatchSupport$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.WaitDispatchSupport.enter(Unknown Source)
	at java.awt.Dialog.show(Unknown Source)
	at java.awt.Component.show(Unknown Source)
	at java.awt.Component.setVisible(Unknown Source)
	at java.awt.Window.setVisible(Unknown Source)
	at java.awt.Dialog.setVisible(Unknown Source)
	at com.inductiveautomation.factorypmi.designer.property.configurators.DynamicOptsDialog.showDialog(DynamicOptsDialog.java:185)
	at com.inductiveautomation.factorypmi.designer.model.VisionDesignerImpl.openBindingDialog(VisionDesignerImpl.java:1087)
	at com.inductiveautomation.factorypmi.designer.property.editors.bb.DynamicOptionsButton.actionPerformed(DynamicOptionsButton.java:36)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at com.jidesoft.plaf.basic.BasicJideButtonListener.mouseReleased(Unknown Source)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at javax.swing.plaf.basic.BasicTableUI$Handler.repostEvent(Unknown Source)
	at javax.swing.plaf.basic.BasicTableUI$Handler.mouseReleased(Unknown Source)
	at com.jidesoft.swing.DelegateMouseInputListener.mouseReleased(Unknown Source)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: com.inductiveautomation.ignition.common.expressions.ExpressionException: Unable to execute view
	at com.automation_pros.simaids.expressions.View.execute(View.java:269)
	at com.inductiveautomation.ignition.client.expressions.ClientDynamicDispatchFunction.execute(ClientDynamicDispatchFunction.java:46)
	at com.inductiveautomation.ignition.common.expressions.FunctionExpression.execute(FunctionExpression.java:69)
	at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:82)
	... 105 more
Caused by: Traceback (most recent call last):
  File "<expression:view>", line 6, in <module>
NameError: name 'value' is not defined

	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:634)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:590)
	at com.automation_pros.simaids.expressions.View.execute(View.java:267)
	... 108 more
Caused by: Traceback (most recent call last):
  File "<expression:view>", line 6, in <module>
NameError: name 'value' is not defined

	at org.python.core.Py.NameError(Py.java:260)
	at org.python.core.PyFrame.getname(PyFrame.java:257)
	at org.python.pycode._pyx14.f$0(<expression:view>:9)
	at org.python.pycode._pyx14.call_function(<expression:view>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1275)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:631)
	... 110 more

Ignition v7.8.5 (b2016120813)
Java: Oracle Corporation 1.8.0_271

```

the code looks like this:

```auto
view("Select * Where value == 0 or value not in args",
  {Root Container.Group.FillerList},
  {Root Container.Group.Dropdown 9.selectedValue},
  {Root Container.Group.Dropdown 10.selectedValue},
  {Root Container.Group.Dropdown 11.selectedValue},
  {Root Container.Group.Dropdown 12.selectedValue},
  {Root Container.Group.Dropdown 13.selectedValue},
  {Root Container.Group.Dropdown 14.selectedValue})

```

I skipped 8 because it is for that dropdown. I put the code as an expessrion binding on the data for the dropdown

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 17, 2022, 7:01pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/15 "2022-08-17T19:01:52Z")

</div>

Column names are case sensitive.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 17, 2022, 7:15pm UTC](https://forum.inductiveautomation.com/t/tag-value-change-script-help/62939/17 "2022-08-17T19:15:56Z")

</div>

ah my bad, missed that. lol. thank you!
