# Client Tag change script

**URL:** <https://forum.inductiveautomation.com/t/client-tag-change-script/53117>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [November 16, 2021, 9:09am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117 "2021-11-16T09:09:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sourabh\_Ambildhuke](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sourabh\_Ambildhuke](https://forum.inductiveautomation.com/u/Sourabh_Ambildhuke)\
**Post date:** [November 16, 2021, 9:09am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117/1 "2021-11-16T09:09:57Z")

</div>

Hi, i need to know when i select 2 tags in tag change script how do i access the second tags like  
first tag value i will access via  
print event.tagPath  
print initialChange  
print newValue  
but how to take new Value of second tag which i have used in tags.  
Urgently needed.

 ![script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/d/1d4cbda6650e65b6d2100bb6eb659b327ec432a7.png)  
 ![tags](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/2/725ae7a83282af47953a96e27e8f99efb055c6ea.png)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 16, 2021, 9:35am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117/2 "2021-11-16T09:35:52Z")

</div>

These events fire for each tag that changes value in those you specify. When it fires, it fires independently for each tag being monitored changes; you don’t get access to other tags being monitored. You will need to read any other tag by using a static path to them and system.tag.readBlocking. In this respect, the gateway tag change scripts behave very similarly to tag change scripts

---

<div class="post-metadata">

**Author:** ![Sourabh\_Ambildhuke](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sourabh\_Ambildhuke](https://forum.inductiveautomation.com/u/Sourabh_Ambildhuke)\
**Post date:** [November 16, 2021, 9:51am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117/3 "2021-11-16T09:51:51Z")

</div>

i am trying to read the tag but it is not working so can you tell me the exact syntax for read.  
I am trying with system.tag.readBlocking("[default]FB\_Process/IT02\_prodtransfer/Prodtransfer\_ctrl").value  
but still i ma unable to read that

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 16, 2021, 10:10am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117/4 "2021-11-16T10:10:09Z")

</div>

It returns a list, so you need  
`system.tag.readBlocking("[default]FB_Process/IT02_prodtransfer/Prodtransfer_ctrl")[0].value`

---

<div class="post-metadata">

**Author:** ![Sourabh\_Ambildhuke](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sourabh\_Ambildhuke](https://forum.inductiveautomation.com/u/Sourabh_Ambildhuke)\
**Post date:** [November 16, 2021, 10:21am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117/5 "2021-11-16T10:21:14Z")

</div>

that syntax is not working in script as i have tried. Also want to know what this [0] stands in syntax

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 16, 2021, 10:24am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117/6 "2021-11-16T10:24:50Z")

</div>

When you say it’s not working, what do you mean?

The `[]` are basic python syntax to read the elements of a list (array). If you’re asking that question though, you really should look at some basic introductory material to the Python language. I think even the IA user manual has some material covering it

[https://docs.inductiveautomation.com/display/DOC81/Python+Scripting](https://docs.inductiveautomation.com/display/DOC81/Python+Scripting)

---

<div class="post-metadata">

**Author:** ![Sourabh\_Ambildhuke](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Sourabh\_Ambildhuke](https://forum.inductiveautomation.com/u/Sourabh_Ambildhuke)\
**Post date:** [November 16, 2021, 10:30am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117/7 "2021-11-16T10:30:23Z")

</div>

yes sure i got the list of array, but still i am facing the same issue i am posting the query and image.  
below image is the tag for which i created script.

 ![tag](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/1/41db31bbb1c61ff9c7784e0e951dcac989b36cb6.png)

the tag is timer tag and i am changing the process based on conditions and timer value.  
and below is the code for the process.

print event.tagPath  
print initialChange  
print newValue

if system.tag.readBlocking("[default]FB\_Process/IT02\_prodtransfer/Prodtransfer\_ctrl")[0].value == 1:  
system.tag.writeBlocking(["[default]FB\_Process/Test\_tags/Timer\_tag"], [1])  
if newValue.value == 1:  
system.tag.writeBlocking(["[default]FB\_Process/VLV4/Mode"], [1])  
system.tag.writeBlocking(["[default]FB\_Process/VLV4/Valve\_status"], [1])  
system.tag.writeBlocking(["[default]FB\_Process/VLV7/Mode"], [1])  
system.tag.writeBlocking(["[default]FB\_Process/VLV7/Valve\_status"], [1])  
system.tag.writeBlocking(["[default]FB\_Process/BL01\_Filling/Fill\_ctrl"], [1])  
system.tag.writeBlocking(["[default]FB\_Process/IT02\_Empty/Empty\_ctrl"], [1])  
if newValue.value == 5:  
system.tag.writeBlocking(["[default]FB\_Process/PU2/Mode"], [1])  
system.tag.writeBlocking(["[default]FB\_Process/PU2/Pump\_status"], [1])  
system.tag.writeBlocking(["[default]FB\_Process/Test\_tags/Timer\_tag"], [0])  
newValue.value = 6  
if newvalue.value == 6 & system.tag.readBlocking("[default]FB\_Process/IT02\_prodtransfer/Prodtransfer\_ctrl")[0].value == 0:  
system.tag.writeBlocking(["[default]FB\_Process/PU2/Mode"], [0])  
system.tag.writeBlocking(["[default]FB\_Process/PU2/Pump\_status"], [0])  
system.tag.writeBlocking(["[default]FB\_Process/Test\_tags/Timer\_tag"], [1])  
if newValue.value == 11:  
system.tag.writeBlocking(["[default]FB\_Process/VLV4/Mode"], [0])  
system.tag.writeBlocking(["[default]FB\_Process/VLV4/Valve\_status"], [0])  
system.tag.writeBlocking(["[default]FB\_Process/VLV7/Mode"], [0])  
system.tag.writeBlocking(["[default]FB\_Process/VLV7/Valve\_status"], [0])  
system.tag.writeBlocking(["[default]FB\_Process/BL01\_Filling/Fill\_ctrl"], [0])  
system.tag.writeBlocking(["[default]FB\_Process/IT02\_Empty/Empty\_ctrl"], [0])  
system.tag.writeBlocking(["[default]FB\_Process/Test\_tags/Timer\_tag"], [0])

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 16, 2021, 10:47am UTC](https://forum.inductiveautomation.com/t/client-tag-change-script/53117/8 "2021-11-16T10:47:00Z")

</div>

Try this. You had a few typos (like using `newvalue` instead of `newValue`), you can’t write to newValue.value, also I converted your individual tag writes into single block writes as this is a lot more efficient in terms of CPU and speed.

```auto
print event.tagPath
print initialChange
print newValue
tagPath = str(event.tagPath)

# this will store the tags and their values to write as a list of lists as [[tagPath1, value1], ..., [tagPathN, valueN]]
tags = []

if system.tag.readBlocking("[default]FB_Process/IT02_prodtransfer/Prodtransfer_ctrl")[0].value == 1:
	tags.append(["[default]FB_Process/Test_tags/Timer_tag", 1])

if newValue.value == 1:
    tags.append(["[default]FB_Process/VLV4/Mode", 1])
    tags.append(["[default]FB_Process/VLV4/Valve_status", 1])
    tags.append(["[default]FB_Process/VLV7/Mode", 1])
    tags.append(["[default]FB_Process/VLV7/Valve_status", 1])
    tags.append(["[default]FB_Process/BL01_Filling/Fill_ctrl", 1])
    tags.append(["[default]FB_Process/IT02_Empty/Empty_ctrl", 1])

elif newValue.value == 5:
    tags.append(["[default]FB_Process/PU2/Mode", 1])
    tags.append(["[default]FB_Process/PU2/Pump_status", 1])
    tags.append(["[default]FB_Process/Test_tags/Timer_tag", 1])
    tags.append([tagPath, 6])
    
elif newValue.value == 6 and system.tag.readBlocking("[default]FB_Process/IT02_prodtransfer/Prodtransfer_ctrl")[0].value == 0:
    tags.append(["[default]FB_Process/PU2/Mode", 0])
    tags.append(["[default]FB_Process/PU2/Pump_status", 0])
    tags.append(["[default]FB_Process/Test_tags/Timer_tag", 1])
    
elfif newValue.value == 11:
    tags.append(["[default]FB_Process/VLV4/Mode", 0])
    tags.append(["[default]FB_Process/VLV4/Valve_status", 0])
    tags.append(["[default]FB_Process/VLV7/Mode", 0])
    tags.append(["[default]FB_Process/VLV7/Valve_status", 0])
    tags.append(["[default]FB_Process/BL01_Filling/Fill_ctrl", 0])
    tags.append(["[default]FB_Process/IT02_Empty/Empty_ctrl", 0])
    tags.append(["[default]FB_Process/Test_tags/Timer_tag", 0])

# write the values to the tags. Note the syntax "list(zip(*tags))" effectively produces a list of columns, where element 0 are the tagPaths and element 1 are the values
system.tag.writeBlocking(list(zip(*tags))[0], list(zip(*tags))[1])

```
