# Gets the last value

**URL:** <https://forum.inductiveautomation.com/t/gets-the-last-value/43650>\
**Category:** Module Development\
**Tags:** ignition80\
**Created:** [February 20, 2021, 9:57am UTC](https://forum.inductiveautomation.com/t/gets-the-last-value/43650 "2021-02-20T09:57:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [February 20, 2021, 9:57am UTC](https://forum.inductiveautomation.com/t/gets-the-last-value/43650/1 "2021-02-20T09:57:52Z")

</div>

In the development of the SDK module, can I directly obtain the last value and time of the tag without queryhistory? For example, if the tag changes from 0 to 10, can I obtain the value 0 and time before 10 in the code

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [February 20, 2021, 11:13am UTC](https://forum.inductiveautomation.com/t/gets-the-last-value/43650/2 "2021-02-20T11:13:54Z")

</div>

you can subscribe for tag change and keep in your module the previous value and timestamp

[http://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.0/com/inductiveautomation/ignition/common/tags/model/TagManager.html](http://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.0/com/inductiveautomation/ignition/common/tags/model/TagManager.html)

`subscribeAsync`

---

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [February 22, 2021, 12:36am UTC](https://forum.inductiveautomation.com/t/gets-the-last-value/43650/3 "2021-02-22T00:36:31Z")

</div>

i see

---

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [February 22, 2021, 1:47am UTC](https://forum.inductiveautomation.com/t/gets-the-last-value/43650/4 "2021-02-22T01:47:31Z")

</div>

When I change value, why does it execute many times (3 times)

```auto
    public void tagChanged(TagChangeEvent tagChangeEvent) throws InvalidListenerException {
                    double random = Math.random();
                    logger.info("value："+String.valueOf(tagChangeEvent.getValue()));
                    logger.info("随机数："+String.valueOf(random));
                    logger.info("路劲"+String.valueOf(tagChangeEvent.getTagPath()));
                }

```

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