Best Practice Question. Tag Event Trigger a HTTP Request

I have a question on a best practice for a tag change script triggering code in the project library.

I have my HTTP request in my Project Library scripts so I can access it everywhere in my project. I have a tag that I would also like to trigger this HTTP request on the change. Problem is my tag change scripts do not have access to my Project Library.

My solution was to create a Gateway Event Message Handler that I can call via a message handle in tag change to run the code in my Project Library. is this the best way to do this?

My main goal is to keep all my code centralized in my Project Library and not have the same code written more than once.

No, probably not.

The best way is to create a Tag Change Script in the same project you defined that script in, and then call it from the change script.

Do not confuse Tag Event Scripts for Tag Change Scripts in this case. Tag Event Scripts are quite sensitive to the speed of execution and would require your project with the library be defined as the Gateway Scripting Project.

I do have a follow up question, if I have more than one tag I want to trigger this Tag Change Script on, can I put them all in the same tag change script or do I need a separate tag change script for each of my UDTs?

For more context my HTTP request is returning data about a product, and I would like to write that back to a document tag. I have my stations setup as UDTs, the order number data comes from a PLC and when that changes this is all fired off.

image

You can configure it like you have in the screenshot. Any of those tags changing will trigger the script.