Button to Redirect to Current Form

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a "Projects" form (Form #1) with a lot of information on it. Inside this form is a details report "Tasks". In order to make it easier on the users, there is a button on the main form, which allows the user to switch the view to a condensed view of the Tasks (Form #2).

The Task details report shown both in Form #1 and Form #2 has a "Work Completed" button, that when pressed, will change a few fields in the Task table and redirects the user back to Form #1.

However, I would like the "Work Completed" button in the details report to return the user back to the same form that they came from. So if they were in Form #1, return to Form #1, if in #2, return to #2.

My buttons work fine, but always return the user back to Form #1. Is there a IF statement that I can add to "check" what form the user is currently viewing and then add the appropriate form ID to the "&dfid=" URL?

Here is my current code:

var text URLONE = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_12=" & URLEncode("Completed");

var text URLTWO = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_99=" & ToText(Today());

var text URLTHREE = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_98=100";

var text URLFOUR = URLRoot() & "db/" & [_DBID_CLIENT]
 & "?a=dr&rid=" & ToText([Related Project]);

$URLONE
& "&rdr=" & URLEncode($URLTWO)
& URLEncode("&rdr=" & URLEncode($URLTHREE))
& URLEncode(URLEncode("&rdr=" & URLEncode($URLFOUR)))
Photo of Michael

Michael

  • 20 Points

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,806 Points 50k badge 2x thumb
Firstly, I think that you can simplify your formula like this, as you are doing 3 edits on 1 record, and not three edits to three different records.



var text URLONE = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_12=" & URLEncode("Completed")
& "&_fid_99=" & ToText(Today())

& "&_fid_98=100";


var text URLTWO = URLRoot() & "db/" & [_DBID_CLIENT]


 & "?a=dr&rid=" & ToText([Related Project]);

$URLONE
& "&rdr=" & URLEncode($URLTWO)







So I think that you said that you have two Projects forms.

When you display a record you can force the form with the dfid parameter.

So it seems to me that you can just have two buttons instead of 1.



var text URLONE = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_12=" & URLEncode("Completed")
& "&_fid_99=" & ToText(Today())

& "&_fid_98=100";


var text URLTWO = URLRoot() & "db/" & [_DBID_CLIENT]


 & "?a=dr&dfid=10&rid=" & ToText([Related Project]);

$URLONE
& "&rdr=" & URLEncode($URLTWO)




So this button above would display the record using Form ID# 10.  You would have another button to display say on form ID# 2.
Photo of Michael

Michael

  • 20 Points
Thanks for the response and the simplified formula. I was trying to stay away from having two buttons. First because the question was a simplification, and I actually have 4 forms and 4 buttons, and second, because having 4 buttons would require 4 different details reports (each one having the appropriate button that takes the user back to the appropriate form), and every time I would have to add/modify a field on the report, I would have to do it 4x times. Thanks again
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,806 Points 50k badge 2x thumb
Hmmm, try this as URL formula field.  It will do the edit and refresh the same page (same form) or report you are on.

var text URL = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_12=" & URLEncode("Completed")
& "&_fid_99=" & ToText(Today())
& "&_fid_98=100";


"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
Photo of Michael

Michael

  • 20 Points
Perfect! Thanks!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,806 Points 50k badge 2x thumb
So you got lucky there.  That magic refresh javascript will only work if you are just doing one QuickBase API call.  Since I was able to combine your three calls into one call, it was OK to use.  But I have found that if you try to combine that whole RDR nesting and use it with that javascript, exactly zippo, nothing, nada, happens.  There is a format to do multiple actions with that javascript but the syntax starts to get crazy and less than intuitive.