# Force an OPC tag to update its value in a script

**URL:** <https://forum.inductiveautomation.com/t/force-an-opc-tag-to-update-its-value-in-a-script/38271>\
**Category:** Ignition\
**Created:** [September 1, 2020, 7:42pm UTC](https://forum.inductiveautomation.com/t/force-an-opc-tag-to-update-its-value-in-a-script/38271 "2020-09-01T19:42:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlos.aguero](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@carlos.aguero](https://forum.inductiveautomation.com/u/carlos.aguero)\
**Post date:** [September 1, 2020, 7:42pm UTC](https://forum.inductiveautomation.com/t/force-an-opc-tag-to-update-its-value-in-a-script/38271/1 "2020-09-01T19:42:03Z")

</div>

I have 5 OPC tags (from a PLC) in a tag group updating every 5 minutes,  
what I want is to get the most recent value when a button is pressed.  
I can’t get the most recent value from the PLC, I keep getting the old value and I need to wait for the 5 minutes to refresh.  
how can I force a tag to get the most recent value from the PLC when I press a button?  
I tried system.tag.scan(“provider”,“Group name”) but that didn’t refresh the values…  
any ideas… Thanks!

thanks!

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [September 1, 2020, 7:52pm UTC](https://forum.inductiveautomation.com/t/force-an-opc-tag-to-update-its-value-in-a-script/38271/2 "2020-09-01T19:52:28Z")

</div>

You didn’t say but I’m assuming by using system.tag.scan your using version 7.9? If so system.tag.scan should force the scan class to run. If your in 8.0 then I think you should use [system.tag.requestGroupExecution()](https://docs.inductiveautomation.com/display/DOC80/system.tag.requestGroupExecution). Depending on what your doing with the data you can also look at using [system.opc.readValues()](https://docs.inductiveautomation.com/display/DOC80/system.opc.readValues). What are you trying to do with the values when you update them?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 1, 2020, 7:53pm UTC](https://forum.inductiveautomation.com/t/force-an-opc-tag-to-update-its-value-in-a-script/38271/3 "2020-09-01T19:53:53Z")

</div>

Use `system.opc.readValues`, and optionally write the results back to the tags if you care to.

Unless your scan class or tag group is in OPC Read Mode then forcing an execution does nothing for the OPC tags in it.

---

<div class="post-metadata">

**Author:** ![carlos.aguero](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@carlos.aguero](https://forum.inductiveautomation.com/u/carlos.aguero)\
**Post date:** [September 3, 2020, 2:14am UTC](https://forum.inductiveautomation.com/t/force-an-opc-tag-to-update-its-value-in-a-script/38271/4 "2020-09-03T02:14:19Z")

</div>

I’m using v8.0.  
I’m just trying to insert the values in a SQL table, but just when the user press the button, but I’d like to have the most recent ones when this happens…thanks for the help!

---

<div class="post-metadata">

**Author:** ![carlos.aguero](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@carlos.aguero](https://forum.inductiveautomation.com/u/carlos.aguero)\
**Post date:** [September 3, 2020, 2:15am UTC](https://forum.inductiveautomation.com/t/force-an-opc-tag-to-update-its-value-in-a-script/38271/5 "2020-09-03T02:15:52Z")

</div>

Hi Kevin,  
system.opc.readValues took care of my issue.  
That worked fine!! Thanks for your help!!
