# HMI tags to Database

**URL:** <https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [April 17, 2020, 6:11am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997 "2020-04-17T06:11:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincent.canda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vincent.canda](https://forum.inductiveautomation.com/u/vincent.canda)\
**Post date:** [April 17, 2020, 6:11am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/1 "2020-04-17T06:11:47Z")

</div>

Hello!

How can i insert HMI tags (data) to database using name queries?

I have a sample here:

 ![tags](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/327effa3f1a3898fc6f07de6ddde99f4a69061a2.jpeg)

I want to insert all this tags data into my database when the record\_trigger turns to “True” (boolean) without using transaction group.

Thank you.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [April 17, 2020, 6:23am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/2 "2020-04-17T06:23:08Z")

</div>

> [@vincent.canda](#):
>
> without using transaction group.

That's exactly what transaction groups were made for. Why not use them?

If you want, you can always script it yourself though: you can run a script on tag change that reads all the values and stores it in a database.

---

<div class="post-metadata">

**Author:** ![vincent.canda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vincent.canda](https://forum.inductiveautomation.com/u/vincent.canda)\
**Post date:** [April 17, 2020, 6:34am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/3 "2020-04-17T06:34:30Z")

</div>

Yeah, i already used transaction groups. I want to verify and validate if all the transactions are captured by using other methods. Based on our checking there is a transaction that skip in the transaction group.

Here is my set up in transaction group:

 ![tran%20group](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3f3f3211cc21f85d62b323842616181eae96c2ad.jpeg)  
When the record\_trigger turns true data on the tags will stored into the databased.  
Is there something wrong with my set up?

Thank you.

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [April 17, 2020, 7:03am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/4 "2020-04-17T07:03:02Z")

</div>

It’s probably a timing issue. OPC UA has timing in scan classes (or groups in Ignition 8). But that timing isn’t deterministic. So if the value goes high and low within the timer, Ignition will never see that value.

It’s better to either let Ignition reset the trigger after execution, or not reset that bit and act on any change.

---

<div class="post-metadata">

**Author:** ![vincent.canda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vincent.canda](https://forum.inductiveautomation.com/u/vincent.canda)\
**Post date:** [April 17, 2020, 7:12am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/5 "2020-04-17T07:12:56Z")

</div>

Thanks for the info.  
Okay sir, i based on my set up. I set the timer into 1 millisecond which means this reason will possible never see the value?  
Regarding the trigger it is a button in the HMI where in if you click it the trigger it will becomes “True”, which means the trigger is already resetting correct me if im wrong.

Thank you

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [April 17, 2020, 7:26am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/6 "2020-04-17T07:26:23Z")

</div>

> [@vincent.canda](#):
>
> Regarding the trigger it is a button in the HMI

You mean an Ignition button? Or a different HMI?

If it's an Ignition button, I would just add a script to the button, and not use any tags as trigger.  
Just use a regular button, and add an "actionPerformed" script.  
Inside that script, get all the tags into variables:

```auto
parameters = {
    "batch_number": system.tag.read("Before Cutting Area/batch_number").value,
    ...
}

```

Then call a named query

```auto
system.db.runNamedQuery("queryName", parameters)

```

And create the named query like this:

```auto
INSERT INTO Table_Name
    ( batch_number, ...) VALUES
    (:batch_number, ...)

```

This approach will make sure you actually see the errors in the client when the button is pressed. And there's less to go wrong in general.

---

<div class="post-metadata">

**Author:** ![vincent.canda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vincent.canda](https://forum.inductiveautomation.com/u/vincent.canda)\
**Post date:** [April 17, 2020, 10:21am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/7 "2020-04-17T10:21:00Z")

</div>

Yeah, its a button from the HMI  
see reference of HMI:

 ![hmi](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/01679dac9faf8c1be6f9cb6771fb1d9a7e854692.png)  
The save button is my Trigger in the tags before\_cutting\_area\_record\_trigger that i used in the Transaction Group.

Regarding script into the button, thanks for the info i get it. but i will try to script it into the textbox that binds to a record\_trigger (Tags), if the value of the textbox is true then call the name query.  
Is that possible?

Thank you.

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [April 17, 2020, 10:36am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/8 "2020-04-17T10:36:16Z")

</div>

Ah, it’s a Siemens HMI, ignore my previous post then.

When you click that button, the PLC sets the `warm_carcass_whole_record_trigger` to 1.  
But the question is, what code is setting that bit back to 0.

You should try to find that code, and disable it. But in Ignition enable the “Reset trigger after execution” checkbox. Then Ignition will set that bit back to 0.

---

<div class="post-metadata">

**Author:** ![vincent.canda](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vincent.canda](https://forum.inductiveautomation.com/u/vincent.canda)\
**Post date:** [April 17, 2020, 10:47am UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/9 "2020-04-17T10:47:14Z")

</div>

Yes, it turns 1 when the HMI button clicked then it reset automatically to 0 after clicked.  
But the problem when i try it into the Transaction Group, sometimes data skipped or doubled. I don’t think if my set up in the transaction group is the problem my execution timer is 1 millisecond.

---

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [April 17, 2020, 7:07pm UTC](https://forum.inductiveautomation.com/t/hmi-tags-to-database/33997/10 "2020-04-17T19:07:40Z")

</div>

I don’t think you need the “only evaluate when values have changed” checkbox checked. When your transaction group timer executes that should evaluate or read the current value of your trigger.

Also, you mentioned the transaction group timer being 1 ms but what is the scan class / tag group of the actual warm\_carcass\_whole\_record\_trigger tag? If that isn’t as frequent as your transaction group timer you might not be evaluating the most recent value.

Transaction groups can certainly get confusing. The documentation in the user’s manual is pretty good at breaking down their order of operations.

[https://docs.inductiveautomation.com/display/DOC80/Understanding+Transaction+Groups](https://docs.inductiveautomation.com/display/DOC80/Understanding+Transaction+Groups)
