Skip to main content
Question

Javascript in Formula URL Help

  • October 4, 2018
  • 0 replies
  • 181 views

From other posts I was able to put together the following code for a Formula URL button.  This accomplishes the main actions of calling a 3rd party REST API and then reloading the current page.   

var text URL= "https://hooks.zapier.com/hooks/catch/XXXXXXXXXXX?;


"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"

I'd like to know if its possible to do one of two (or both) additional actions

1.  Is it possible to add a delay before the page reloads?
2.  Is it possible to show a pop-up box the user would click on and then reload the page

I basically just need to buy a second or two while the REST API that was called does its thing and then ultimately updates a record back in Quickbase before the page reload occurs

Thanks for the help
This topic has been closed for replies.

  • Registered
  • October 4, 2018
For the first one is straight forward, below is the timeout function, i use a fat arrow function with no input, and call location.reload(true) after 2 seconds or 2000 milliseconds.

setTimeout(()=> location.reload(true),2000) 

  • Registered
  • October 4, 2018
As for the popup box, there are so many ways to do this, for the sake of expedience have a look at Dans pastie in the below link, his pastie collection is a good starting point in extreme cases or a good resource to save time in general as you are starting your Javascript adventure in quickbase.

https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=7&rl=w2v


  • Registered
  • October 4, 2018
$.get is shorthand for a jquery Ajax (Asynchronous JavaScript and XML) call.  The asynchronous nature of this allows for exactly what you are looking to do in a non-blocking way.

You just need hit up a .then() or similar after your API call.

Here are some docs:

https://api.jquery.com/jquery.get/
More stuff: https://api.jquery.com/category/ajax/

Hope this helps,

~Rob