# Multiselect dropdown writing to multiple tags

**URL:** <https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [October 13, 2022, 12:12am UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144 "2022-10-13T00:12:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 13, 2022, 12:12am UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/1 "2022-10-13T00:12:49Z")

</div>

I have a dropdown that is multiselectable and I have a UDT that has multiple tags that I want to write to.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/9/3928048135eed20e8a21befcd1310bc94e55733a.png)

How do I structure my writeBlock to write to multiple tags in that UDT?

---

<div class="post-metadata">

**Author:** ![calimero100582](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/calimero100582/32/18630_2.png) [@calimero100582](https://forum.inductiveautomation.com/u/calimero100582)\
**Post date:** [October 13, 2022, 12:51am UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/2 "2022-10-13T00:51:23Z")

</div>

Write blocking receive a list of tag, and a list of value.

If you want to set the selected tags to 1

```auto
if !isinstance(Pos, list):
    Pos = [Pos]

Val = [1 for x in Pos]
system.tag.writeBlocking(Pos, Val)

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 13, 2022, 9:11am UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/3 "2022-10-13T09:11:52Z")

</div>

> [@calimero100582](#):
>
> `if !isinstance(Pos, list):`

Unlike pretty much every other language, which use `!`, Python uses `not` for negation:

```python
if not isinstance():

```

> [@calimero100582](#):
>
> ```auto
> Val = [1 for x in Pos]
> 
> ```

I like `[1] * len(Pos)`

---

<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:** [October 13, 2022, 11:51am UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/4 "2022-10-13T11:51:40Z")

</div>

You will also need to generate a list of tag paths to write to.

So, something like:

```python
tagValues = self.getSibling("Dropdown").props.value
if tagValues:
    parentPath = '[default]_types_/'
    members = ['Test 1','Test 2','Test 3']

    tagPaths = [parentPath + member for member in members]

    system.tag.writeBlocking(tagPaths,tagValues)

```

However, there are some fundamental problems here, like how do you know which value works with which tag?

What is the ultimate goal, why does this selection need to be a tag?

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 13, 2022, 1:04pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/5 "2022-10-13T13:04:24Z")

</div>

Here is more of what im doing.

```auto
	BadgeNum = self.getSibling("Table").props.selection.data[0].EmployeeID
	Name = self.getSibling("Table").props.selection.data[0].Name
	Line = self.getSibling("Line_Dropdown").props.value
	Pos = self.getSibling("Pos_Dropdown").props.value
	
	
	
	system.tag.writeBlocking('[default]Phase 1 Extrusion/'+str(Line)+'/'+str(Line)+'_'+str(Pos)+'/Assigned Operator BadgeNum',BadgeNum)
	system.tag.writeBlocking('[default]Phase 1 Extrusion/'+str(Line)+'/'+str(Line)+'_'+str(Pos)+'/Assigned Operator Name',Name)

```

I am trying to use this so supervisors can assign an operator multiple positions to work at with the dropdown like this:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1a88c660557446160926f51a5c7bb63403e545a0.png)

I believe they need to be tags because I have a UDT that has several instances made from it; i.e, L41,L42,L51...etc and each one of those will have multiple positions that can be assigned to an operator.

---

<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:** [October 13, 2022, 1:14pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/6 "2022-10-13T13:14:57Z")

</div>

Okay, so the drop down is actually to build the tag paths, that clears things up.

```python
BadgeNum = self.getSibling("Table").props.selection.data[0].EmployeeID
Name = self.getSibling("Table").props.selection.data[0].Name
Line = self.getSibling("Line_Dropdown").props.value
Pos = self.getSibling("Pos_Dropdown").props.value

if Line and Pos:
	parentPath = '[default]Phase 1 Extrusion/{0}/{0}_{1}/Assigned Operator '.format(Line,Pos)
	tags = ['BadgeNum','Name']
	
	tagPaths = [parentPath + tag for tag in tags]
	tagValues = [BadgeNum, Name]
	
system.tag.writeBlocking(tagPaths, tagValues)

```

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 13, 2022, 1:21pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/7 "2022-10-13T13:21:50Z")

</div>

I get this error:

com.inductiveautomation.ignition.common.script.JythonExecException  
Traceback (most recent call last):  
File "function:runAction", line 22, in runAction  
ValueError: Invalid path element '[default]Phase 1 Extrusion/L41/L41\_: [u'Pos1', u'Pos2']/Assigned Operator BadgeNum': Illegal character '\<' (Line 1 , Char 36)

```
caused by org.python.core.PyException

```

Traceback (most recent call last):  
File "function:runAction", line 22, in runAction  
ValueError: Invalid path element '[default]Phase 1 Extrusion/L41/L41\_: [u'Pos1', u'Pos2']/Assigned Operator BadgeNum': Illegal character '\<' (Line 1 , Char 36)

---

<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:** [October 13, 2022, 1:24pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/8 "2022-10-13T13:24:48Z")

</div>

You apparently have multi-selected two positions, and the code is trying to stick both into a single tagpath. You will have to iterate, or disallow multi-select.

---

<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:** [October 13, 2022, 1:31pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/9 "2022-10-13T13:31:07Z")

</div>

oops, sorry missed the important part. 🤦🏻‍♂️

```python
BadgeNum = self.getSibling("Table").props.selection.data[0].EmployeeID
Name = self.getSibling("Table").props.selection.data[0].Name
Line = self.getSibling("Line_Dropdown").props.value
Pos = self.getSibling("Pos_Dropdown").props.value

if Line and Pos:
	parentPaths = ['[default]Phase 1 Extrusion/{0}/{0}_{1}/Assigned Operator '.format(Line,p) for p in Pos]
	tags = ['BadgeNum','Name']
	
	tagPaths = [parentPath + tag for parentPath in parentPaths for tag in tags]
	tagValues = [BadgeNum, Name] * len(Pos)
	
	system.tag.writeBlocking(tagPaths, tagValues)

```

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 13, 2022, 1:36pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/11 "2022-10-13T13:36:10Z")

</div>

Thanks. I am getting same error still, i am looking into.

---

<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:** [October 13, 2022, 1:39pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/12 "2022-10-13T13:39:13Z")

</div>

Can you show an example BadgeNum?

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 13, 2022, 1:43pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/13 "2022-10-13T13:43:23Z")

</div>

A badgeNum looks like this: 0038014279

The error is this:  
Invalid path element '[default]Phase 1 Extrusion/L41/L41\_: [u'Pos1', u'Pos2']/Assigned Operator BadgeNum': Illegal character '\<' (Line 1 , Char 36)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 13, 2022, 1:45pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/14 "2022-10-13T13:45:09Z")

</div>

That's the same error you had previously. Are you sure you used the new code and saved everything ?

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 13, 2022, 1:53pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/15 "2022-10-13T13:53:45Z")

</div>

> [@lrose](#):
>
> `format(Line,p) for p in pos]`

I see now what it was, pos was lower case so it didnt see Pos/ when I changed it to Pos It seems to be doing ok

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:** [October 13, 2022, 1:55pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/16 "2022-10-13T13:55:56Z")

</div>

Fixed it in the original script.

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [October 13, 2022, 1:56pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/17 "2022-10-13T13:56:51Z")

</div>

Thanks alot guys, Big Help!

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [January 18, 2023, 7:29pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/18 "2023-01-18T19:29:07Z")

</div>

How could I add Shift into this scripted you help me with? I needed to add shift memory tags. When the system.tag.writeBlocking executes I need it to go to where it orignially was and this new path. Im just not sure how to add Shift to the parentPaths list

```auto
BadgeNum = self.getSibling("Operator_Table").props.selection.data[0].EmployeeID
	Name = self.getSibling("Operator_Table").props.selection.data[0].Name
	Line = self.getSibling("Line_Dropdown").props.value
	Pos = self.getSibling("Pos_Dropdown").props.value
	Shift = self.session.custom.Shift
		
	if Line and Pos:
		parentPaths = ['[default]Phase 1 Extrusion/{0}/{0}_{1}/Assigned Operator '.format(Line,p) for p in Pos]
		tags = ['BadgeNum','Name']
			
		tagPaths = [parentPath + tag for parentPath in parentPaths for tag in tags]
		tagValues = [BadgeNum, Name] * len(Pos)
		
		system.tag.writeBlocking(tagPaths, tagValues)
		
		'''parentPaths = ['[default]Phase 1 Extrusion/{0}/{0}_{1}/{2} Shift Operator Name '.format(Line,p) for p in Pos]
		tags = ['BadgeNum','Name']
					
		tagPaths = [parentPath + tag for parentPath in parentPaths for tag in tags]
		tagValues = [BadgeNum, Name] * len(Pos)
				
		system.tag.writeBlocking(tagPaths, tagValues)'''

```

---

<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:** [January 18, 2023, 7:45pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/19 "2023-01-18T19:45:45Z")

</div>

If I'm understanding what you're trying to accomplish, I believe it would be this:

```auto
parentPaths = ['[default]Phase 1 Extrusion/{0}/{0}_{1}/{2} Shift Operator Name '.format(Line,p,Shift) for p in Pos]

```

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [January 18, 2023, 8:04pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/20 "2023-01-18T20:04:13Z")

</div>

I would like for it to write in both locations, the assigned operator and the shift operator. Could it happen like this? When I run the script it doesnt return an error but it doesnt write to the tag address either:

```auto
	BadgeNum = self.getSibling("Operator_Table").props.selection.data[0].EmployeeID
	Name = self.getSibling("Operator_Table").props.selection.data[0].Name
	Line = self.getSibling("Line_Dropdown").props.value
	Pos = self.getSibling("Pos_Dropdown").props.value
	Shift = self.session.custom.Shift
		
	if Line and Pos:
		parentPaths = ['[default]Phase 1 Extrusion/{0}/{0}_{1}/Assigned Operator '.format(Line,p) for p in Pos]
		tags = ['BadgeNum','Name']
			
		tagPaths = [parentPath + tag for parentPath in parentPaths for tag in tags]
		tagValues = [BadgeNum, Name] * len(Pos)
		
				
		system.tag.writeBlocking(tagPaths, tagValues)
		
		parentPaths1 = ['[default]Phase 1 Extrusion/{0}/{0}_{1}/{2} Shift Operator Name '.format(Line,p,Shift) for p in Pos]
		tags1 = ['BadgeNum','Name']
					
		tagPaths1 = [parentPath + tag for parentPath in parentPaths1 for tag in tags1]
		tagValues1 = [BadgeNum, Name] * len(Pos)
				
		system.tag.writeBlocking(tagPaths1, tagValues1)

```

---

<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:** [January 18, 2023, 8:18pm UTC](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144/21 "2023-01-18T20:18:14Z")

</div>

Assuming that the tag paths are correct, there is no reason doing it that way wouldn't work.

However, I would suggest that you can go a bit further. You'll need to make sure that the tag paths are correct.

```auto
	BadgeNum = self.getSibling("Operator_Table").props.selection.data[0].EmployeeID
	Name = self.getSibling("Operator_Table").props.selection.data[0].Name
	Line = self.getSibling("Line_Dropdown").props.value
	Pos = self.getSibling("Pos_Dropdown").props.value
	Shift = self.session.custom.Shift
		
	if Line and Pos:
		parentPaths = ['[default]Phase 1 Extrusion/{0}/{0}_{1}/Assigned Operator '.format(Line,p) for p in Pos]
		tags = ['BadgeNum','Name']
			
		tagPaths = [parentPath + tag for parentPath in parentPaths for tag in tags]
		tagValues = [BadgeNum, Name] * len(Pos)
		
		parentPaths1 = ['[default]Phase 1 Extrusion/{0}/{0}_{1}/{2} Shift Operator Name '.format(Line,p,Shift) for p in Pos]
		tags1 = ['BadgeNum','Name']
					
		tagPaths1 = [parentPath + tag for parentPath in parentPaths1 for tag in tags1]
		tagValues1 = [BadgeNum, Name] * len(Pos)
		
		system.tag.writeBlocking(tagPaths + tagPaths1,tagVaues + tagValues1)

```

You can use code like this to print the tag paths to the console and verify they are correctly formed

```auto
for path in tagPaths1:
	system.perspective.print(path)

```

[Next page](https://forum.inductiveautomation.com/t/multiselect-dropdown-writing-to-multiple-tags/65144.md?page=2)
