Effective way to log data on a given time interval

Hi all,

I've been working on logging data on a specific time interval through a scripting transform. The only problem with this is it runs multiple times per instance of the conditional statement evaluating to true.

Which looks like this:
image

The transform itself looks like this:

Is there anyway I can force this transform to only run once per conditional being true?

Note: 'value' is simply a 60 second countdown that refreshes for as long as another components timer is active

Thank you,

Cam

Why don't you just use a Gateway Timer Script, as opposed to a binding? Or is your expectation to do this for every open Session/Page?

It is expected to run for every open session in the system :slight_smile:

Okay, then there are multiple concerns here.

  1. The sleep calls you've placed are only semi-blocking, as that transform runs every time the binding updates; if it updates before you've completed the last script, then you now have two instances of the transform executing. In the event of rapid updates, you're going to see all sorts of weird logging. Never sleep in transforms, and I recommend against writing that data out anywhere. If you need to record the values, then you should use a change script. This would also allow you to specify that the value should only be recorded when different from its previous value.
  2. You're not actually using the ID variable as part of your query, so EVERY session is going to be recording values without any sort of way to discern which session the values belong to.

One way to do this would be to have an expression binding of now(60000) on some custom property. With that binding in place, add a change script to the property which runs your named query.

This seems to have done the trick. Thank you :smiley:

1 Like