Forum Discussion
ScottMarks
7 years agoQrew Member
You could always have your API call redirect to ANOTHER API call that then modifies the end time with Now(). That way, no matter how long someone is on the page, the Now() is always called on the second half and is always "up to date".
//First section of your API call that changes record values n such, Now() is not included in this part..
URLRoot()&"db/"&Dbid()&"?a=API_EditRecord&rid="&[Record ID#]&"&apptoken=xxxxxxx&<DO YOUR STUFF HERE FIRST>
//Second section which executes the NOW() function, which has been "refreshed" in a second api call.
&"&rdr="&URLRoot()&"db/"&Dbid()&"?a=API_EditRecord&rid="&[Record ID#]&"&apptoken=xxxxxxx&_fid_19=Now()
- QuickBaseCoachD7 years agoQrew CaptainScott, that won't work.
If you did that formula and exposed the code, you would see that it is all resolved into a text string URL and the second Now() is immediately populated.
I'm still liking the Action method, myself. Trigger an Action to do the update if you really need the Now() time. - ScottMarks7 years agoQrew MemberHmm actually you're right. My mistake.
Perhaps you could redirect to a code page that takes the rid url param, as well as dbid and use some javascript to run a call after the fact with the current time.
I think that should work, I'll see if I can setup a demo. - ScottMarks7 years agoQrew MemberAlright, so to start this method off...
You will need the following code page:<HTML> <HEAD> <title>Refresh Time</title> <script type="text/javascript"> var urlParam = function(name, w){ w = w || window; var rx = new RegExp('[\&|\?]'+name+'=([^\&\#]+)'), val = w.location.search.match(rx); return !val ? '':val[1]; } var dbid = urlParam('dbid'); var rid = urlParam('rid'); var fid = urlParam('fid'); var token = "YOUR TOKEN HERE"; var base_url = window.location.origin; var date = new Date; function refresh(){ window.location.replace(base_url + "/db/" + dbid + "?a=API_EditRecord&rid=" + rid + "&apptoken=" + token + "&_fid_" + fid + "=" + date); } </script> </HEAD> <BODY> <script>refresh()</script> </BODY> </HTML>
Lastly, you will need to format your INITIAL API call to redirect to this page.
As said in a previous post, it'll be something like this:URLRoot()&"db/"&Dbid()&"?a=API_EditRecord&rid="&[Record ID#]&"&apptoken=xxxxxxx&<DO YOUR STUFF HERE FIRST>&"&rdr=<LINK TO NEW .HTML CODE PAGE WITH SCRIPT>&rid="&[Record ID]&"dbid="&Dbid()&"fid=<YOUR FID HERE>&rdr="&<YOUR FINAL REDIRECT LINK>
After you sift through and correct the inevitable syntax errors, and probably adjust the Javascript Date function to output correctly for QB formatting, this should solve your issue.
Scott - ScottMarks7 years agoQrew MemberThat said, the action trigger method is much simpler. :^)
EDIT: And you can actually skip the JS date function, and just use "=Now()" at the end of the redirect in the code page instead of the "=" + date piece. Derp.