Countdown timer with action in the end

Recently I discovered the _Delay() hidden formula. With it, now it is possible to make delayed actions.

How it works:
_Delay(actionOrValue, timeoutInMillis) — will perform action or resolve to value after given timeout.

If set up on a button, the button will remain in “loading” state until timeout fires.

You can use this for e.g. Pomodoro docs and alike.

Demo:

8 Likes

This is awesome. You can use _Noop()._Delay(ms) as “sleep” to make the code more elegant.

RunActions(
  ModifyRows([Timer vars], [Fire at], Now() + Seconds([Countdown seconds])),
  _Noop()._Delay([Countdown seconds] * 1000),
  ModifyRows([Timer vars], [Fire at], ""),
  OpenWindow("https://www.youtube.com/watch?v=bjxf-eQWKoo")
)
2 Likes

Did you try it? Won’t it execute actions 3 and 4 right away, and only delay the _Noop() by x seconds?

Yep, I’m using it right now. RunActions executes sequentially, so there you have in order: Modify > Delay > (Noop) > Modify > Open

1 Like

Interesting. I tried it with _Delay(some value, [Countdown seconds] * 1000), it modified rows and opened the window without waiting for the delay action to finish.

Thanks for the tip!

Hey people, I’m trying to use _delay() with FormulaMap to delay the sending of each email to a list, i.e. I want one email to be sent, and a delay of say 30 seconds, and then the next one etc, so they aren’t all sent at the same time. This is my forumla at the moment:

FormulaMap(
thisRow.Recipients, _delay(
Gmail::SendEmail(
[User’s private Gmail account],
CurrentValue.Email,
thisRow.Subject,
thisRow.[Email Body]
), 30000)
)

But all the emails are sent at the same time! Any idea how to use _delay in this case to achieve this?

Ok after much tinkering, I figured out that if I add the _delay() as a runaction() with a _noop(), before the Gmail Send action, it does stagger the sends, i.e.:

FormulaMap(
thisRow.Recipients,
RunActions(
_delay(_noop(), 60000),
Gmail::SendEmail() etc…

4 Likes