Skip to main content
Question

Refresh Current Time before Creating or Editing Records

  • July 13, 2016
  • 0 replies
  • 85 views

I have a set of URL formulas that run in a Formula -Text field when a button is clicked.

I'm invoking 2 sets of URLs in an HREF from pre-defined variables as follows:

&$URLeditlast& "&rdr=" & URLEncode($URLnew)& 

The URLeditlast URL puts a stop time in on a current record, the URLnew creates a new record with a start time.  This is the basis of a time tracking system

The problem is if the user leaves the page sitting idle the time doesn't' refresh. 

For example, if I create my new time entry at 4:49pm and the leave the page sitting for 10 minutes then click the button to create a new entry, the times recorded is still 4:49pm, not 4:59pm.  

I know if the user refreshes the page before they click the button this would solve the problem, however I do not want the user to have to do this (i have over 100 users in this quickbase all day long and there would be risk of time errors if people forget to refresh).  I would like the QuickBase self-refresh when the button is clicked and then run the two URLs above to perform the actions with hopefully a refreshed time value

I've tried many things and cannot get this to work, i'm hoping someone has some ideas.  Thanks!

This topic has been closed for replies.

This will require JavaScript to capture the time.  You will likely need to contract with a developer to get to the solution you want.

  • Registered
  • July 22, 2016
This is easy to do. Post your complete formula.

  • Registered
  • September 30, 2016
We had this issue as well and resolved it with an onmouseover.

var text base = URLRoot() & "db/" & Dbid();
var text rdr = "&rdr=" & URLEncode($base & "?a=dr&rid=" & [Record ID#]);
var text url = $base & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid_<TARGET FID>=";

var text jquery="$(\"#timeTarget\").attr(\"href\",\""&$url&"\"+ now.replace(\",\",\"\") + \""&$rdr&"\")";

"<a id='timeTarget' href ='void' class='Vibrant' onmouseover='"&"var now = new Date().toLocaleString();"&$jquery&" '>BUTTON NAME</a>

  • Registered
  • September 30, 2016
Here is a better one I think, it is fully self-contained, uses an interval to refresh automatically and provides an output, make a field with whatever name you want.

var text base = URLRoot() & "db/" & Dbid();
var text rdr = "&rdr=" & URLEncode($base & "?a=dr&rid=" & [Record ID#]);
var text url = $base & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid_15=";

"<div id='rdr' value='"& $rdr &"'/>" &
"<div id='url' value='"& $url&"'/>" &

var text timeScript = "setInterval(function(){var d=new Date(); var cDate = d.toLocaleString().replace(',',''); var eDate = encodeURI(cDate); $('#timeTarget').text('Time ('+cDate+')'); var t= $('#url').attr('value') + eDate + $('#rdr').attr('value'); $('#timeTarget').attr('href',t);},1000);";

var text script = "(function(){"&$timeScript&"})();";

"<img src=' '  onerror=\"javascript: "&$script&" \"></img>"&

"<a id='timeTarget' href ='void' class='Vibrant'>Time</a>"

  • Author
  • Registered
  • September 30, 2016
I tried your first version, works amazingly well and solves a problem i've been trying to solve for a long time.  This is awesome, thank you so much!

  • Registered
  • September 30, 2016
Anytime, I would recommend the second one just because I am always nervous a user will break it, they always find a way, with the second one using a interval, it updates no matter what.