Return to page after Edit Record formula text button.

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
I use the code:
"javascript:" &
"$.get('" & 

$URLONE &

"',function(){" &

"location.reload(true);" &

"});" 

& "void(0);"

to return to the same page a lot in my app and it works incredibly well.  However I only use it on formula URL's and I am wondering what I need to change to make it work on a formula text button instead.  Here is the code:


var text URLONE = "<a class='Vibrant Success' href=" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]  & "&_fid_56=true" & "> IA Documents Approved </a>";

"javascript:" &

"$.get('" & 

$URLONE &

"',function(){" &

"location.reload(true);" &

"});" 

& "void(0);"

Does this code need to be in a formula URL or is there a better way to refresh the page after editing the record?  Thanks in advance.
Photo of Jacob

Jacob

  • 758 Points 500 badge 2x thumb
  • Frustrated

Posted 2 years ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
The java reload syntax needs to be part of your href in the formula text button.  Or you can make a formula URL field that has all the action, and just reference it in the formula text field.

"<a class='Vibrant Success' href=' " & [URL Formula Field] & " '> IA Documents Approved </a>"
That's really useful...  Thanks Matthew!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,290 Points 50k badge 2x thumb
fwiw, i have never been able to get the javascript reload working in conjunction with those href Vibrant buttons, so I'm sitting on the sidelines here to see if it can be done.

I have it working when a "redirect" (rdr) is used but not for the more useful javascript refresh syntax.  (ie more useful as it works universally regardless of if you are on a record or a report).
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
Correction to the syntax, I copied the wrong button.

If you want the reload to happen within the formula text button you have to nest the quotes.

With Reload java:
href=\""&[URL Formula Field]&"\"

with a RDR:
href=' " & [URL Formula Field] & " '

Sorry if that throws you off.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,148 Points 50k badge 2x thumb
Thx Matthew for posting this and helping the Community
Photo of QuickBasePros_IDS

QuickBasePros_IDS, Champion

  • 3,770 Points 3k badge 2x thumb
Generally, to use color-buttons I use a button for "View" mode (reports and view-form layouts) and a separate one for Edit.  The color choice of the button would be Success (green), Danger (red) and Primary (blue).

For Edit-Mode

  "<a class='Vibrant Success' title='Start' href='#' style='text-align:center; display:block' onclick=\"" & "javascript:$(function(){window.location.href='" &
  URLRoot() & "db/" & [_DBID_TABLE_ALIAS] & "?act=API_EditRecord&apptoken=xxxxxxxxxx&rid=" & URLEncode([Record ID#])
  & "&_fid_6=" & URLEncode("Text")
  & "&_fid_8=" & URLEncode(User())  
  & "&_fid_7=" & URLEncode(Now())
  & "&rdr=' + escape(window.location); return false;});"
  &"\">Button Label Here</a>"

For View-Mode/Reports

"<a class='Vibrant Success' title='Start' style='text-align:center; text-decoration:none' href='javascript:void(window.location.href = \"" & 
  URLRoot() & "db/" & [_DBID_TABLE_ALIAS] & "?act=API_EditRecord&apptoken=xxxxxx&rid=" & URLEncode([Record ID#])
  & "&_fid_6=" & URLEncode("Text")
  & "&_fid_8=" & URLEncode(User())  
  & "&_fid_7=" & URLEncode(Now())
  & "&rdr=' + escape(window.location); return false;});"
  &"\">Button Label Here</a>"

Hope this is helpful.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,290 Points 50k badge 2x thumb
Laura, thx for wading in with a most useful answer.
Photo of Jacob

Jacob

  • 758 Points 500 badge 2x thumb
Thank you all for your responses.  These answers will definitely solve some of the issues that I am having right now.  See you all at Empower in a month!