URL Formula Button Refresh current page not Redirect

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
What I have now is an application dashboard for our Director to select a name of a manager. Then it takes them to individual Dashboards with ALL of the reports for that one manager on the page for employee performance metrics (measured across multiple tables and entry points). One report on the dashboard is a "Address at the next 1:1" list. On the report i have a URL button field that changes the status from "Address" to "Closed" so that the director can just click on the button without editing each record every time just to change status and save. One click entry without leaving the dashboard view.

Since i cannot redirect to the main table dashboard (since she would have to select the name and re-enter the specific employees dashboard). I would like for the page to just refresh itself on the current dashboard. Keep in mind that i cannot code a specific dashboard since there are 40+employee dashboards each with a different URL that utilize the same table, but different reports.



Here is what i have:

URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]

& "&_fid_12="&URLEncode("Closed")


& "&rdr=" & URLEncode(URLRoot() & "db/INSERT THE MAIN TABLE ID YOU CAN FIND THIS BY CLICKING HOME") <--I cannot use this because i want to just refresh current page





Found this suggestion on further research, but it gives me "Formula Syntax Errors" when i add this to the bottom of the code below

"javascript:" &

"$.get('" &


$URL &


"',function(){" &


"location.reload(true);" &


"});"


& "void(0);"




Any help is greatly appreciated

Photo of ARademacher

ARademacher

  • 0 Points

Posted 5 years ago

  • 0
  • 1
Xavier Fan posted that info and while I have not tested it yet myself, it should work.



Try this and do my testing for me. make a formula variable to define $URL and then the code should work. Let us know how it goes.


var URL =


URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]

& "&_fid_12="&URLEncode("Closed");

"javascript:" &

"$.get('" &


$URL &


"',function(){" &


"location.reload(true);" &


"});"


& "void(0);"
Photo of ARademacher

ARademacher

  • 0 Points
That is the exact problem i am having.  I am not able to find anything that will define the $URL as the current page we are on now. I keep getting syntax errors when i use this.. Something else i just tried

URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_12="&URLEncode("Closed")
& "&rdr=" & URLEncode(URLRoot() & "javascript:location.reload(true))")  <-but the java is not able to be used like that, but at least i get to a 404 error page and can hit my back button.   

Any other ideas to define $URL as the current page?


The above sample did not work.

var URL = ??******MISSING FORMULA TO DEFINE THE CURRENT PAGE URL*******??

URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]

& "&_fid_12="&URLEncode("Closed");

"javascript:" &

"$.get('" &

$URL &

"',function(){" &

"location.reload(true);" &

"});"

& "void(0);"
You did not try what I suggested.
I gave you the exact code to try but it had a small syntax error.  This is tested.


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

"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
Juan
You should clearly state your question in a new post and perhaps just reference this post with a link as we have no idea what your code is.
Photo of Juan

Juan

  • 480 Points 250 badge 2x thumb
Sorry, I was just referring to the example to which I added my comment:

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

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

I noticed that the edit action does not always get executed, although the refresh (reload) does. Sometimes the records just don't get updated.

I'll create a new post if I still need an answer. Thanks!
Try this
var text URL = 
URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_12="&URLEncode("Closed");

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

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
You'll need an apptoken
Also, note that you should only show the button in Edit or View mode.  You cannot edit a record which does not yet exist.
Photo of dwhawe

dwhawe, Champion

  • 908 Points 500 badge 2x thumb
This worked for me
Yes, its a really handy technique now!
Photo of Xavier Fan

Xavier Fan, Champion

  • 800 Points 500 badge 2x thumb
Glad it worked!
Photo of Drew

Drew

  • 522 Points 500 badge 2x thumb
This is so very extremely helpful.
Photo of ARademacher

ARademacher

  • 0 Points
This solution did work.  Thank you so much for all of your help!!
Photo of Kerry-Ann

Kerry-Ann

  • 40 Points
Hi, Can you explain how I would set this up with a status change button?
Kerry-Ann
Did you try code like this?

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

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

In that example, the field being updated is field ID#12
Photo of Kerry-Ann

Kerry-Ann

  • 40 Points
I have an if statements set up, like the following, how would I apply this java to this?

If([Status]="Ready to Start",
URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&apptoken=b2ef6ijciijsibdf9dftgdjtdhm3"
& "&_fid_15="&URLEncode("In Progress")
& "&_fid_284="&URLEncode(Today())
& "&rdr=" & URLEncode(URLRoot() & "db/bkpvkgvbb"),

[Status]="In Progress",
URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&apptoken=b2ef6ijciijsibdf9dftgdjtdhm3"
& "&_fid_15="&URLEncode("Completed")
& "&_fid_285="&URLEncode(Today())
& "&rdr=" & URLEncode(URLRoot() & "db/bkpvkgvbb")
& "&_fid_29="&URLEncode(Today()), null)
OK, so now I am confused as to what you real question is.

What are you trying to do that is not working?  This technique does not support the "rdr=" ....
Photo of Kerry-Ann

Kerry-Ann

  • 40 Points
Sorry. I really just want each time a person clicks to change the status button that the page refresh and stay on the same page. Can I still use this code? If so, how would I use it?
Try this
var text URL =
If([Status]="Ready to Start",
URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&apptoken=b2ef6ijciijsibdf9dftgdjtdhm3"
& "&_fid_15="&URLEncode("In Progress")
& "&_fid_284="&URLEncode(Today()),

[Status]="In Progress",
URLRoot() & "db/" & Dbid () & "?act=API_EditRecord&rid=" & [Record ID#]
& "&apptoken=b2ef6ijciijsibdf9dftgdjtdhm3"
& "&_fid_15="&URLEncode("Completed")
& "&_fid_285="&URLEncode(Today())
& "&_fid_29="&URLEncode(Today()));


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

please check the code for the In progress - are you wanting to update two different date fields?
Photo of Kerry-Ann

Kerry-Ann

  • 40 Points
That worked perfectly! Thank you so much!
:) the nice thing about that technique is that it will work on any record or report and not need multiple buttons.
Photo of Tony

Tony

  • 226 Points 100 badge 2x thumb
Hi Everyone:

Would this be sufficient to have the auto refresh happen?

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

Or does it need the everything that proceeded?  This is what my existing button looks like:

var  text  pdfid = Case([Company], "UMB", "8", "9");var  text  fname = Case([Company], "UMB", "UMB Assignment Form", "Assignment Form");
"javascript:void(window.open('" &
"https://www.aws-juiced-client2.com/CompleteMedical_946/PDF Stamper/Default.aspx?"
& "clientid=Q946"
& "&appid=bkkhaw4q7"
& "&msdb=" & Dbid()
& "&msid=" & [Patient Number]
& "&tpdbid=" & [_DBID_DOCUMENT_TEMPLATES]
& "&tpid="  &$pdfid
& "&faid=444"
& "&apptoken=cidsvuqba48bsbbdntgghv5dzec"
& "&fn="&$fname
& "&pdfdte="
& "&rsfid=14"
&"','copy','top=40,left=320,width=730,location=no,menubar=no,toolbar=no,status=yes'))"


So should I just add the javascript after that?  

Thanks in advance!
Photo of Matthew Neil

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
I could be wrong, but I don't think you can run 2 JavaScript actions in one button...
In this situation I don't think you'll be able to use the standard reload with this.

You main formula is already using a "window.open" call, so you would need to include a close function as part of that main call.

something like
{if (a.closed) {window.location.reload();}}

but I'm not 100% of the syntax in your situation.
Photo of Tony

Tony

  • 226 Points 100 badge 2x thumb
The developer I'm working with found a workaround.  THANKS!
Photo of Clayton Rountree

Clayton Rountree

  • 264 Points 250 badge 2x thumb
I'm interested in modifying the javascript above to include a location redirect in the script. 

var text DisplayRecord=
URLRoot() & "db/" & [_DBID_TASKS_POC]
& "?a=td";

"javascript:" & 
"$.get('" & $AddRecordOne & "').then(function(){" &
"$.get('" & $AddRecordTwo & "').then(function(){" &
"$.get('" & $AddRecordThree & "').then(function(){" &
"$.get('" & $AddRecordFour & "').then(function(){" & 
"$.get('" & $AddRecordFive & "').then(function(){" &
"$.get('" & $AddRecordSix & "').then(function(){" &
"$.get('" & $AddRecordSeven & "').then(function(){" &
"$.get('" & $AddRecordEight & "').then(function(){" &
"$.get('" & $AddRecordNine & "').then(function(){" &
"$.get('" & $AddRecordTen & "').then(function(){" &
"})" & 
"})" & 
"})" & 
"})" & 
"})" & 
"})" & 
"})" & 
"})" & 
"})" & 
"});"
& "void(0);"

Where do I insert $DisplayRecord? I've tried numerous different spots, can't get it to work. Thanks in advance!