Create a delay with a script

Hi Everyone!

I’m trying to set a 5-10 seconds delay for an automation.

I’ve checked this post :
https://community.airtable.com/t/i-need-a-delay-method-settimeout-is-undefined-not-found-window/28125

And I’ve tried the following script:

function timeout(ms) {
   return new Promise(resolve => setTimeout(resolve, ms));
 }
await timeout(50000)//waits 5 seconds

The editor gives an error and my automation can’t complete.

Do you have any clue of how I can (A) fix this issue or (B) set a delay in a different way ?

Regards,

Is a longer delay okay? If so, check out this support article.

Overtly blocking a non-blocking architecture is generally a risky idea; it often leads to brittle and unexpected outcomes.

It’s always good to explain why you need a delay because there may be different pathways to achieve the automated process without a delay.

You’re right, here is my full problem.

I’m using an Airtable Web Clipper to get a screenshot
Then I’m using one automation (on the new record created) to use the screenshot as an attachment to a Twitter message.

The problem is that the screenshot takes a few seconds to completely download into the new record. Meanwhile, the automation is already starting and finally, the tweet isn’t generated because Airtable considers that there’s no image in the field.

Introducing a short delay, would allow me to bypass the initial problem I have.

Perhaps you could force the web clipper step to perform one additional step - set a field as “Step One Complete” and then force the next step as a dependency on the final step of the previous process.

Another idea - since you are adept with script, why not simplly use a while (!notSaved) loop or a looped try-catch process checking for the availability of the clipped image?

2 Likes