Force refresh a page after webhook has changed data

  • 1
  • 1
  • Question
  • Updated 1 year ago
  • In Progress
I am using a webhook to update some tasks (ex. task B and C) as complete in a table once a particular task (task A) is marked as complete. So when I mark task A as complete, the page is refreshed and it removes A from the list since it's completed. In the background, the webhook is triggered and it updates B and C as complete. 

However, I still see B and C visible when the page is redirected after I change task A. I believe there is a delay while the webhook is making changes, therefore, I have to refresh the page a second time to see the change. I don't want to have our users refresh the page twice every time they make these updates.

Is there a way to force reload a page in this scenario? Or any other solution that might help here?

Thanks.
Photo of Rizu

Rizu

  • 210 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,372 Points 20k badge 2x thumb
If you are familiar with networking concepts you can think of a webhook as similar to a UDP Packet - it may or may not arrive. If you need a page refresh after some user action you should use script instead as the script can immediately react to user actions.
Photo of Rizu

Rizu

  • 210 Points 100 badge 2x thumb
Thanks Dan.

So just for clarification, rather than using a webhook altogether I should use script to perform cascading updates in this case and refresh the page when the data has been changed. Correct?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,372 Points 20k badge 2x thumb
Sounds good to me - the devil is in the details.
Photo of Rizu

Rizu

  • 210 Points 100 badge 2x thumb
Thanks!
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
If script is not your strength, you can also do this with the current relationships you have.  And using formulas to automatically "complete" sequential tasks.

I know Dan is a master at script and a great advocate for it, but I thought I'd give you another option
Photo of Heather Bryant

Heather Bryant

  • 922 Points 500 badge 2x thumb
Hi Matt,
I am working with a Quick Base Action and am running into the same as Rizu mentioned above - the 1 or 2 second delay and having to refresh 2 times.

I am working with a summary field in a master table and because of the refresh issue, it is not getting populated because essentially the child record hasn't yet been created to populate it.

You mentioned using a formula as work around, what would that look like?

Thanks! 
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,372 Points 20k badge 2x thumb
This is a fundamental problem with Webhooks - in the current implementation you can't chain Webhooks together in a reliable way and because they are rate limited you can't even guarantee the initial Webhook will fire in the first place.

But there is an easy solution using script. If you use the API to mark task A as complete you can further process task B and C only after task A's processing is completed. This property of chaining together asynchronous processes is called "thenable". Webhooks are not "thenable" in their current implementation but there are simple ways to make API calls "thenable" (ie chainable) using jQuery or the Fetch API.
(Edited)