# Tag Change Help

**URL:** <https://forum.inductiveautomation.com/t/tag-change-help/70968>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [March 13, 2023, 4:08pm UTC](https://forum.inductiveautomation.com/t/tag-change-help/70968 "2023-03-13T16:08:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nruimveld](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@nruimveld](https://forum.inductiveautomation.com/u/nruimveld)\
**Post date:** [March 13, 2023, 4:08pm UTC](https://forum.inductiveautomation.com/t/tag-change-help/70968/1 "2023-03-13T16:08:55Z")

</div>

Hello all!

I currently have a script that needs to save a value to a tag.

client = system.net.httpClient()  
location\_id = '1234'  
token = '1234'

params = { 'location': location\_id, 'start\_time': '2023-03-13 00:00', 'end\_time': '2023-03-13 00:10', 'data\_type': '2' }

response = client.get('[https://www.someurl.com/](https://www.someurl.com/)', params = params, headers = headers)  
system.tag.write('Tag Name', response.json)

In the above script, start\_time and end\_time need to change every 10 minutes to get the updated value and then written to the tag. Currently, I have the tag set up as a Memory but I'm not quite sure if it needs to be done as a Gateway Tag Change or as an event on the tag itself.

Any info would be greatly appreciated, thank you!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 13, 2023, 4:22pm UTC](https://forum.inductiveautomation.com/t/tag-change-help/70968/2 "2023-03-13T16:22:58Z")

</div>

1. Put your script into a project library package (e.g., named `utils`):

```python
_client = system.net.httpClient()

def getLocationInfo(location_id, token, start_time=None, end_time=None):
	date_format = "yyyy-MM-dd HH:mm"

	if start_time is None:
		start_time = system.date.now()
	start_time = system.date.format(start_time, date_format)
	if end_time is None:
		end_time = system.date.addMinutes(start_time, 10)
	end_time = system.date.format(end_time, date_format)

	params = { 
		'location': location_id,
		'start_time': start_time,
		'end_time': end_time,
		'data_type': '2'
	}

	response = client.get('https://www.someurl.com/', params = params, headers = headers)
	return response.json

```

1. Set your 'Gateway Scripting Project' to the project that contains the project library.
2. Create an expression tag. Make sure it's set to 'event driven' execution.
3. Give it an expression like this:  
`runScript("utils.getLocationInfo", 1000 * 60 * 10, 'locationId', 'token')`

`runScript` will automatically trigger at a ten minute rate. The function will be invoked with the passed in arguments, which will automatically end up as now and now + 10 minutes.

---

<div class="post-metadata">

**Author:** ![nruimveld](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@nruimveld](https://forum.inductiveautomation.com/u/nruimveld)\
**Post date:** [March 13, 2023, 6:28pm UTC](https://forum.inductiveautomation.com/t/tag-change-help/70968/3 "2023-03-13T18:28:00Z")

</div>

@paul-griffith What do you mean by Set your 'Gateway Scripting Project' to the project that contains the project library? Do I create a new script under the Project Library and name it utils?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 13, 2023, 6:35pm UTC](https://forum.inductiveautomation.com/t/tag-change-help/70968/4 "2023-03-13T18:35:47Z")

</div>

To use runScript in an expression tag, you need to have your gateway scripting project (set in the gateway settings via the web interface) defined. You will want to create a project, a project library script within it, and use that reference in the expression. You don't have to use the actual name utils, just make sure the names line up.

---

<div class="post-metadata">

**Author:** ![nruimveld](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@nruimveld](https://forum.inductiveautomation.com/u/nruimveld)\
**Post date:** [March 13, 2023, 6:54pm UTC](https://forum.inductiveautomation.com/t/tag-change-help/70968/5 "2023-03-13T18:54:35Z")

</div>

I am getting an Error\_Configuration. I'm sure I'm probably messing up some where.
