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*******");




});


});

1 Like

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

Thank you @TonyLewis75327 for sharing all of this! I had some luck gaining inspiration from you and @JulianKirkness post https://www.onlinedatabase.expert/post/knack-and-integromat-waiting-for-a-response. I wanted to do exactly Julian did but triggered by an action button. So, I had the action button’s submit rule go a modal popup page that had a form on it with no input variables. I added the javascript below that automatically submits that form, and that’s the form I used to trigger Julian’s code that triggers the Integromat scenario and then waits for the response. I coded the response from Integromat to add a link in the response message directly to the page I need the user to go by adding the page record ID in the hyperlink. Works like a charm and I NEVER would have gotten there without you guys…THANK YOU!

/* Change the scene_1 to the scene key of your choice. */
$(document).on(‘knack-scene-render.scene_1’, function(event, scene) {
// Knack Standard Theme:
$(‘button[type=submit]’).submit();

// Legacy: Classic and Legacy: Flat Themes:
$('input[type=submit]').submit();

});

Thats great im glad it helped! I like your solution too. I’ve got a new method I figured out you might like, I’ll try to find some time this week to show how I did it.

Oh wow…I’d love to see it. Thank you again!!