Inconsistent results using this API_EditRecord
I have a form setup with buttons that capture the current time on a button click. It works great using both a code page or just running the code in the URL formula field. But I've found an issue that I can't seem to find a solution for. Maybe it's with the code, or maybe it's something else entirely.
I found this code in the Magic Buttons app and tweaked it a little for our purposes.
var text urlToExecute = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&apptoken=APP_TOKEN" & "&rid=" & [Record ID#] & "&_fid_62="&ToTimeOfDay(Now());
URLRoot() & "db/" & AppID() & "?a=dbpage&pageid=56" & "&url=" & URLEncode($urlToExecute)
--------------------------
I've also used this successfully without calling the code page;
URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&apptoken=APP_TOKEN"
& "&rid=" & [Record ID#] & "&_fid_62="&ToTimeOfDay(Now())
--------------------------
The issue I'm having is after I use one button to run the code and update the field with the current time, I'll wait for a period of time, several minutes or a few hours, then I click a different button coded the same but with a different field id, and it populates the field with the same time from the first button click, not the current time. It acts like it ignores the Now() function and uses the last time from memory, or something like that. But when I click it again it works correctly.
I was also able to duplicate the same results in the Magic Button app by setting up a second button and text field. I hit the second button and it put the same time, not the current time, in the other field.
This seems like a refresh issue. If I manually refresh the page before clicking the next button I get the current time. So I tried appending code to refresh the page.
& "&rdr=" & URLEncode(URLRoot() & "db/" &Dbid() & "?a=dr&rid=" & [Record ID#])
That didn't work, so I tried appending code to redirect to a table report
& "&rdr=" & URLEncode(URLRoot() & "db/" &Dbid() & "?a=q&qid=8")
No good there either. I tried the app's home page
& "&rdr=" & URLEncode(URLRoot() & "db/" & AppID()),
no success. No matter what I do, short of logging out and back in, or a manual refresh, it will still use the same time that it previously used.
This is all from a desktop using Chrome. I can duplicate it in other browsers, and it behaves the same using the mobile app.
I would appreciate any insight into this issue. It just makes no sense why it would be using the same time when it's calling the Now() function.
------------------------------
Barry Dolan
------------------------------