Roster Management - best way to run a script on changes to rosters

We are using a script that uses the system.alarm.getRosters function to pull out the users in each roster and put it in a dataset memory tag which we want updated every time a change is made. The dataset memory tag is then used elsewhere.

The problem I’m having is finding out the most efficient way to trigger the script which writes to the dataset memory tag. I tried using the Roster management extension function “onSaveRoster”, but after making a change to a roster, it first runs the script with the old roster, then saves the new changes. So the dataset memory tag is outdated unless I go in and do a save again (with no changes) which picks up the change from the first time.

The Roster Management doesn’t have any built in properties that change, so the best I thought of is making a custom method of type date, and run an expression of now(5000) for example to run periodically, but that means it would be running the script needlessly at times. Any better way to do this? Thanks

So shortly after posting this, I may have come up with something. I put in a delay to the system.util.invokeLater and it does seem to work now.

For example, on the Roster Management component , I created a custom method with the script to write to the dataset memory tag (uses system.alarm.getRosters and such). On the “onSaveRoster” extension, I put system.util.invokeLater(self.newMethod, 5000).

Without the delay argument, the invokeLater didn’t work (race condition?)

We ran into issues like this and scrapped the idea of using Ignitions built in roster and created our own tables, screens, etc. We then use calculated rosters. It obviously takes a little more time to get going but it is more robust and configurable.