Delay page redirect after Submit

I have a 'parent' form that when submitted, redirects to a record details page for the newly created record that shows the parent record along with a few 'child' connected records created by an integromat scheme that is triggered by the parent submit.

It takes the integromat scheme a few seconds to run though, and more often than not the redirect to the details page after the form submit beats the time it takes the integromat scheme to make the child records, causing the details page to look like there aren't any child records. You have to give it a few seconds and then refresh the details page, at which point the child records will show up.

So, my question is: Is there a way to submit the parent form, then create a pause for a few seconds before redirecting to the details page? My users are ok sitting through a few seconds of delay if it means they don't have to refresh the page to see the child records.

Here is what the scenario looks like webhook listener at the beginning and webhook return at the end to signal to the javascript its done and send a 200 success

![](upload://ArBEwhsAW50Tpws1W3XtrzOLuAo.png)

How i usually do this is with an action link. I'll call an action link that calls a modal popup with a empty detail in in the view. soon as the detail renders it runs this below which makes the modal popup disappear immediately then blanks the screen showing the spinner which then runs the webhook to integromat and when it's finished it drops the spinner and moves back to the original modal.

Here is a screen recording of it working: https://take.ms/Xo9Go

$(document).on('knack-view-render.view_983', function(event, view, data) { 


console.log(JSON.stringify(data, 2, 2));
console.log(event.key);
console.log("******Modal Pop*******");

// CSS Hide Modal
$(".kn-modal.default" ).hide();
console.log("******HIDE Modal*******");


setTimeout(function(){
Knack.showSpinner();
console.log("******SHOW Spinner*******");
console.log('FIRST TIMER 1 SECOND');
}, 2000);

commandURL = "https://hook.integromat.com/xxxxxaaddsfasfasdfasd?recordid=" + data.id ;

$.get(commandURL, function(data, status){
console.log("Data: " + data + "\nStatus: " + status);


Knack.hideSpinner();
console.log("******HIDE Spinner*******");
window.history.back();
console.log("******HISTORY Back*******");




});


});

Well Tony I wouldn't have thought of that!

I've gone the opposite route:

  • Knack form submit initiates a setTimeout loop to check for an updated flag in a record.
  • The loop refreshes part of page containing the flag and keeps the spinner going - one page we even use a progress bar.
  • Integromat scenario finishes on updating the flag.
  • Knack then redirects.

Stacks of Javascript though.

The way I have synchronized Integromat with Knack is by instead of using a watch record module in Integromat I use a webhook and call Integromat through javascript and a webhook listening module.

So I setup a javascript listener in knack for the submission of the form and when the form is submitted i have a simple GET request that sends out the webhook to Integromat with the RecordID of what I need Integromat to act on. Then I throw up the Knack spinner so the system shows its waiting and the Integromat scenerio then runs and at the end of the scenerio i use a webhook response module that sends back a 200 reponse meaning all good. This returns continues the Javascript listener I take down the spinner and let Knack continue loading the page I'll send a refresh views command for good measure so it updates all views on the page

Let me know if you need anymore details about this its easier than it sounds if you aren't that great at javascript