Scheduled Gateway Event / on Demand

I have a Gateway Event Script Set to run twice a Day. Is there a way to manually force this script to run by user input without having a second copy of the script?

What I want is for the script to run twice a day or whatever I set the schedule for, but also to run a single time with user input (button click), but not have the script in 2 different places.

Put the logic in a project script. Then call the project script from the gateway event to invoke it on your twice-a-day schedule or from a button when needed on-demand.


This, always. While you can write entire scripts in the dialog for your event, you should not. For best maintainability, and for other uses, event scripts should be one-liners that just pass all the relevant event information to a project library script.

I have the script put in project library and Scheduled event to call it. If I want a button to call it would the best way be to screen button --> changes tag [RunXScriptTag] then have gateway tag change script monitor [RunXScriptTag] to call the function instead of having the screen button calling the function directly?

No, if you go through a tag, then your clients aren't independent. Just call the script from the button.

I tried that at first but it locked up the client. Script is quite large, checking a DB table against tag values and correcting if needed. Takes about 2 min to run if no changes and can be much longer if it finds and corrects errors. I don't need more then 1 client to run it at any time. This is an administration level operation so the "button" would be restricted access and rarely used.

Run it on a background thread using system.util.invokeAsyncornous() and system.util.invokeLater() if needed.

There are multiple posts on the forum on how to accomplish that.

Or system.util.sendMessage to run it on the gateway. Add some locking/exclusivity in the message handler before actually invoking the slow code.