Replacing Query Tags with REST API

In my project, I have about 300 UDTs that contain query tags.

The table they currently reference will be removed soon and replaced by an API.

Since I have only used REST calls for single, standalone tasks and never on this scale, I was wondering what the best approach would be to populate this data using REST calls.

Thanks.

Do you still have access to some type of database for making tables?

Yes, I have a MSSQL DB for my tables that I can manage.

Consider using runScript() expressions instead of query bindings, and have your script cache all of the results in a top-level dictionary. Only call out to the API for missing values.

1 Like

The current query binding is similar to this code:

SELECT * FROM MyTable

WHERE ProductionOrder = 'actualOrder'

where actualOrder is a UDT tag. The result is usually a dataset with about 80 columns and 150 rows.

The current advantage is that the query is executed only when the ProductionOrder value changes.

@pturmel I don’t understand what you mean with “cache all of the results in a top-level dictionary

Thank you for the help.

search the forum for this terminology to see discussions on it, but basically you have a global variable in a project script that caches your api results. You only need to use the API if it doesn't already exist in the dictionary.
examples:
Global Scripting Variables (Library Script Top-Level Vars) - Ignition - Inductive Automation Forum
Imperial/Metric conversion: Where do you put your single source of truth? - Ignition - Inductive Automation Forum

1 Like

Thanks for the links, I didn’t know about this. :+1: