Formula URL Button not returning to record or table

  • 0
  • 2
  • Question
  • Updated 2 years ago
  • Answered
  • (Edited)
I have a table of Files/Links that need to be acknowledged by a subcontractor. I created a Formula URL button using advice from another post that is about 1 year old. 
The goal is this: when the contract downloads the files or uses the link, he/she is then to "Acknowledge" having done so. So a formula URL fills in the user name, date/time and a "Status" in a status field and saves the record.

It all worked PERFECTLY except that after the "Acknowledge" button is pressed, despite all the records (Name, Date/time and Status" being properly updated, the result leaves the user on a blank white webpage with the following text:  
"API_EditRecord 0 No error 2 1 1492657399140"

Instead of returning the user to the table that was showing when the button was pressed, or the record if one record was opened.

I thought the final line of the text would do the trick, but it's not working:

URLRoot() & "db/" & [_DBID_ART_RELEASE_FILES___LINKS]
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_13 =1-Downloaded" & "&_fid_10=" & ToText(User()) & "&_fid_12=" & ToText(Now()) & "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxx" & "&z=" & Rurl()
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb

Posted 2 years ago

  • 0
  • 2
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
This button appears on the report link that it currently shows up and when clicked, would return back to the parent record with the update report link, instead of opening up the child record. In this case, the user won't need to open the child record, because he/she can access the link or the file from the report link in the parent record.
only users of a different ROLE will be able to fully open and edit the records. 
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
I think you have two directions you can go.

If you want the satus update button to refresh the page (regardless of where its pushed, you'll want to use something like this;

var text URL=URLRoot() & "db/" & [_DBID_ART_RELEASE_FILES___LINKS]
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_13 =1-Downloaded"
& "&_fid_10=" & ToText(User())
& "&_fid_12=" & ToText(Now())
& "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxx";
"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"

An alternative if you want the button to download the file, and run the api edit in one button push, use something like this;

URLRoot() & "db/" & [_DBID_ART_RELEASE_FILES___LINKS]
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_13 =1-Downloaded"
& "&_fid_10=" & ToText(User())
& "&_fid_12=" & ToText(Now())
& "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxx
&rdr="&URLEncode(URLRoot() & "up/" & Dbid () & "/a/r" & [Record ID#] & "/e87/v0/") 

(just remember to change the "e87" to the field ID of your file attachment field. "eXX")

I bet you could get all 3 together, but I don't have time to test it right now.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,372 Points 20k badge 2x thumb
As long as you are insisting on placing JavaScript in your formulas you should at least use ES6 features:

var text URL=URLRoot() & "db/" & [_DBID_ART_RELEASE_FILES___LINKS]& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_13 =1-Downloaded"
& "&_fid_10=" & ToText(User())
& "&_fid_12=" & ToText(Now())
& "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxx";
"javascript:" &
"$.get('" & 
$URL & 
"',() => location.reload(true));" 
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
Is there an alternative to the javascript?
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
Success. Thank you both!