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()
ScottMarks
7 years agoQrew Member
Alright, so to start this method off...
You will need the following code page:
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:
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
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