Multiple conditions for a boolean tag change

I have a popup window that is supposed to appear and be mandatory to fill out. It is supposed to appear by either being triggered manually via a button, or automatically. The automatic part is the tricky part here - it should not be done more than once an hour (so if it was manually triggered 30 minutes ago, should be at least another 30 minutes until it is triggered again), and I need to make sure it happens after a certain % of the work order is done (it makes no sense to have workers check a case for accuracy if there are no cases done yet). Also there should not be more than one check per work order.

Ideally, here is how it should work. There is a work order started. A few cases of products are complete. My pop up is triggered and filled out. Now, when we are in another work order, at least an hour away, where at least 10 cases are done, we can trigger it again automatically (if it hasn’t been triggered manually already).

Database tables I can use - acd_history database table has a column end_t_stamp, when the last popup window was finished. I figure this is the best way to make sure I am at least an hour out.

Database table workorders - sequentially kept, and perhapes an on change of the latest id would be a trigger for the new work order? Additionally this table has a column actualCases, which represents how many cases have been completed thus far in the work order, I want it to be at least 10 cases to be done before running.

My thought process on how to do this right now is to have a Tag, I think an expression tag, that will run be scanned once a minute - is the current workorder the same as the workorder of the last acd_history row? Is there at least 10 cases in the db for the last row, and is there at least an hour difference between the last row in acd_history and now. If all these are true, and all conditions are met, and then open my popup.

Now that I write this out, I feel like actually I should have this expression tag calling a python script once a minute to figure this out and open the window. I’m wondering if anyone else has any better ideas on how to go about this multi-conditional tag change that triggers a window opening.

Just use a client timer script. Hold the last check timestamp in a client tag, preloading it on startup from your DB. Whenever the script runs (once a minute or so) you check that the prior is far enough in the past and that enough work has been done. If it is time, update that timestamp and open the popup

1 Like