Delay Function

I am receiving a payload through a webhook and would like to “delay” it before it flows downstream to other lookup and import steps. It seems like this may have been an enhancement request a few years back, but was this innovation ever rolled out for use in the platform? If not, is there a solution/work around for what I am trying to do?

Original Post I found below:
undefined

Hi Dave… the “delay function” is on a short list of things we want to do in 1H'25. So, sorry … not quite there yet.

Given that we are looking to add that feature, I'd like to know more about the scenario you have in mind. Is there a certain number of seconds/minutes you need? How confident are you in that scenario that “N seconds” will produce the result you need? I'm assuimng it may not be 100%, so wondering how you plan to react upon failure even if that wait period. Thoughts?

@daveguderian to clarify, are you needing this because you want to hold records and then just run held records on a schedule? Or you need to hold records for lets say 1 minute so that activities in the source system can take place prior to making the lookup? For example, if a record comes in and another record comes in 30 seconds later, would you want the first record to go 1 minute after we received it and the second 1 minute after it was received? Or would you want, all records received from 12pm-1pm all go together at 1:01pm?

@tylerlamparter - I would just want to hold the payload (record) for a minute and then release each individual record after the minute was up to process through the rest of the flow. It wouldn't be a batch job, but rather a record by record delay.

Example: Record one comes in through webhook at 11AM…. holds till 11:01AM and is released to process through rest of flow. Record two comes in at 11:04AM and would be released at 11:05AM to process through the rest of the flow.

@daveguderian why are you needing the delay? @tonycurcio22 also had a few questions which would be helpful to know to validate how we've planned it aligns with what you're needing.

Hey @tylerlamparter - Is there a way to delay a payload today using JavaScript? I keep running into an error (see below) and didn't want to spend much more time if this wasn't possible.

function preSavePage(options) {
   // Function to block execution for a certain number of milliseconds
   function delay(milliseconds) {
       const start = new Date().getTime();
       while (new Date().getTime() - start < milliseconds) {
           // Intentionally empty to block execution
       }
   }
   // Delay time in milliseconds (2 minutes)
   const delayTime = 120000; // 2 minutes
   // Introduce the delay
   delay(delayTime);
   // Modify the data or pass it through as-is
   const modifiedData = options.data.map(record => {
       // Add any modifications to the record here if needed
       return record;
   });
   // Return the modified data after the delay
   return {
       data: modifiedData,
       errors: options.errors,
       abort: false,
       newErrorsAndRetryData: []
   };
}

@daveguderian so if I understand correctly, you basically have 2 flows, each flow is triggered by a webhook event and you want one flow to wait for the other flow to finish prior to completing some steps on this flow? The JavaScript route won't work as it has a strict time out limit.

Thats correct @tylerlamparter ! I will note that the second flow, however, is not receiving anything from the first flow. The second flow is webhook where it receives a payload from an AWS Lambda function.

@daveguderian as opposed to having two flows, is there a reason it's not just 1 flow that receives the payload and then orchestrates it? Are the payloads between the two flows different?

The reason is the second flow is receiving payment token information returned from lambda (lambda interacts with a third party payment processor).

@daveguderian even with a delay, there isn't really any guarantee that the other flow would be finished in X amount of time. So you could still end up in scenarios where you'd get an error thrown for the account not existing. Personally, I would just make a 3rd flow that grabs the errors from flow 2, then calls our api to retry the errors. That third flow could then be set to run every 5min.

Its kind of complicated to explain but in short, we are sending information out to a third party and they are returning identifiers to us and we have to match to an existing account in SF. The issue is, we have another flow running simultaneously to create the account in SF, but sometimes that account isnt created before the third party returns their info, and so when we try to do a lookup to the account it doesn't find a match (since the account hasnt been created yet).

We would like to delay/hold that third party payload when we receive it through the webhook for “x” minutes to ensure the other flow has had time to complete and create the account.

Hopefully that makes sense!

@tonycurcio22 & @tylerlamparter - I think this was being targeted for early this year. Do you have any updates on when this might be released. This is still something I am very much interested in!

Thanks!

Hi @daveguderian .... we put it down our backlog a few notches given some other priority work.

I know you discussed in the past with the team and I think had a workaround... but, did you hit another use case where this is required?

Hi,

I'm also interested to know when this functionality will be implemented. I haven’t encountered a new use case yet, but it's definitely something that has been on my radar as well.

1 Like