# How to log multiple tag when one tag value change?

**URL:** <https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [December 6, 2023, 6:06am UTC](https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763 "2023-12-06T06:06:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://forum.inductiveautomation.com/u/govind)\
**Post date:** [December 6, 2023, 6:06am UTC](https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763/1 "2023-12-06T06:06:29Z")

</div>

Hello Friends,

I want to log multiple tags using of the one tag value change.

For example : 100 tags log when the tag\_1 value change.

Thanks & Regards,

Govind Suthar

---

<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:** [December 6, 2023, 6:31am UTC](https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763/2 "2023-12-06T06:31:57Z")

</div>

I believe that's a typical use case for transaction groups.

[https://docs.inductiveautomation.com/display/DOC81/Understanding+Transaction+Groups#UnderstandingTransactionGroups-TriggerSettings](https://docs.inductiveautomation.com/display/DOC81/Understanding+Transaction+Groups#UnderstandingTransactionGroups-TriggerSettings)

---

<div class="post-metadata">

**Author:** ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://forum.inductiveautomation.com/u/govind)\
**Post date:** [December 6, 2023, 6:38am UTC](https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763/3 "2023-12-06T06:38:51Z")

</div>

Hello dear,

Thanks for reply,

Yes, I already tried with transaction groups. But, i want to log using tag historian module.

---

<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:** [December 6, 2023, 6:45am UTC](https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763/4 "2023-12-06T06:45:02Z")

</div>

That seems like the wrong tool for the job, but I guess you can script it with [system.tag.storeTagHistory](https://docs.inductiveautomation.com/display/DOC81/system.tag.storeTagHistory) when your monitored tag change.  
Also, when you have requirements like this, please explain them upfront. Though if that's not a requirement but simply something you want... I suggest you reconsider and use a transaction group.

---

<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:** [December 6, 2023, 12:48pm UTC](https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763/5 "2023-12-06T12:48:33Z")

</div>

> [@govind](#):
>
> using tag historian

The tag historian simply does not work that way, sorry. Use a transaction group. Or script the equivalent on a tag change event.

---

<div class="post-metadata">

**Author:** ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://forum.inductiveautomation.com/u/govind)\
**Post date:** [December 7, 2023, 10:52am UTC](https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763/6 "2023-12-07T10:52:50Z")

</div>

How it work through script. could explain it with example?

---

<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:** [December 7, 2023, 1:17pm UTC](https://forum.inductiveautomation.com/t/how-to-log-multiple-tag-when-one-tag-value-change/82763/7 "2023-12-07T13:17:19Z")

</div>

Sure. I would normally configure a gateway tag change event with a one-line delegation to a script library function, like so:

```auto
someScript.someFunction(initialChange, event)

```

Then, in the library script `someScript`, I'd have something like this:

```auto
from java.lang import Throwable

logger = system.util.getLogger(system.util.getProjectName() + '.' + __name__ )

tagsForSomeFunction = ['path/to/tagA', 'path/to/tagB']
opcForSomeFunction = ['[device1]path/to/itemA', '[device2]path/to/itemB']
opcServer = 'Ignition OPC UA Server'

sqlForSomeFunction = """
INSERT INTO some_table (t_stamp, trigger, all_good, tag_a, tag_b, item_a, item_b)
VALUES (?, ?, ?, ?, ?, ?, ?)"""

def someFunction(initialChange, event):
	if initialChange:
		return
	t_stamp = system.date.now()
	triggerValue = event.currentValue.value
	tagQVs = system.tag.readBlocking(tagsForSomeFunction)
	opcQVs = system.opc.readValues(opcServer, opcForSomeFunction)
	
	allGood = all([qv.quality.good for qv in (tagQVs + opcQVs)])
	params = [t_stamp, triggerValue, allGood] + [qv.value for qv in (tagQVs + opcQVs)]
	try:
		rowCount = system.db.runPrepUpdate(sqlForSomeFunction, params, 'someDatabaseName')
	except Throwable, t:
		logger.warnf("Failed to insert for event=%s, values=%s", [event, repr(params)], t)
		return
	if allGood and rowCount:
		logger.tracef("Data reads and Insert success for event=%s", event)
	else:
		logger.infof("Incomplete read/insert, rowCount=%s, event=%s", rowCount, event)

```

Note that any constants used are assigned outside the function -- they will persist.

You are responsible for creating the target table and any indices it will need.
