Skip to main content

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.



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.


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?


Hi @Cedric_NIEUTIN,


The next solution is not the best way to do this, but it was the only way I find, as they blocked the “settimeout” function.


function delay(ms) {
var limit = new Date();
limit = limit.setMilliseconds(limit.getMilliseconds() + ms);
while ((new Date()) < limit) {
// do nothing
;
}

delay(1000); //delay 1 second

I found this on StackOverflow, so credits for that guy, but I really think it´s awful !!! haha


The thing is that this blocks entirely the script and it´s not very recommended, but in my case, I only needed a 1-second delay so it was better than building another automation workflow.


Hope that it helps


Sergio


Hi @Cedric_NIEUTIN,


The next solution is not the best way to do this, but it was the only way I find, as they blocked the “settimeout” function.


function delay(ms) {
var limit = new Date();
limit = limit.setMilliseconds(limit.getMilliseconds() + ms);
while ((new Date()) < limit) {
// do nothing
;
}

delay(1000); //delay 1 second

I found this on StackOverflow, so credits for that guy, but I really think it´s awful !!! haha


The thing is that this blocks entirely the script and it´s not very recommended, but in my case, I only needed a 1-second delay so it was better than building another automation workflow.


Hope that it helps


Sergio



That help me a lot!! Thank you.


There is a missing “}” at the end, here is the right code:


function delay(ms) {
var limit = new Date();
limit = limit.setMilliseconds(limit.getMilliseconds() + ms);
while ((new Date()) < limit) {
// do nothing
;
}
}

delay(9000); //delay 9 second

maybe a slight hack around this - i simply put in a formula field which = 1 when there is an attachment in the attachment field


and then run the automation from the formula being updated rather than the attachment field …


seems to work with a 20MB file…


Reply