URL Button on the report saving the record but showing the record

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

URL Formula Field: Press to Complete

URLRoot() & "db/" & Dbid() 

& "?act=API_EDITRecord&rid=" & [Record ID#]

& "&_fid_12=Completed"

& "&_fid_99=" & Today()

& "&disprec=1"


1. I have this formula setup on my Tasks table(child). In My project table when someone goes in and click on the button Complete, it changes the status field(12) to completed and changes the Completion date(99) to today's date but instead of redirecting it back on the same project page, after clicking this button it is taking them to the view record page(it is working) but I want the user to stay on the same page after they click complete. so in an ideal world, click on the button, change the status, put the completion date and stays on the same page. 


2. Second issue, my formula puts todays date but then it wipes out the next day so that date is not sticking on the task record. 


Please advise!

Photo of AZ

AZ

  • 40 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
Try this

var text URLONE = URLRoot() & "db/" & Dbid()

& "?act=API_EDITRecord&rid=" & [Record ID#]

& "&_fid_12=Completed"

& "&_fid_99=" & Today();

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

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

I'm assuming your Table name is Projects.


As for the value for Today, changing back to blank, there must be something else happening, perhaps you have a Form Rule or some other formula URL updating that field.
Photo of AZ

AZ

  • 40 Points
Hello Mark - Thank you for the answer. Here is the error I am getting ...
Formula error -- Unknown field

This table does not contain a field called _DBID_PROJECTS. To see available fields, click the Fields & Function dropdown to the right of the formula box.

Yes the name of the table is projects. Where can I find the dbid for the table?
Photo of AZ

AZ

  • 40 Points
One more thing to add....This button is actually appearing on a Tasks Report which is in Table (Tasks) and then this report is embedded in the Project Table inside each project with related tasks.
Photo of AZ

AZ

  • 40 Points
I want to reroute it to the same page where someone click complete button. whether it is in project tables, on the homepage, or in tasks table.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,806 Points 50k badge 2x thumb
OK, here is the answer you are looking for.  I did not post it originally because it looks scary even though it's actually simpler to use.



var text URLONE = URLRoot() & "db/" & Dbid() 

& "?act=API_EDITRecord&rid=" & [Record ID#]

& "&_fid_12=Completed"

& "&_fid_99=" & Today();




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




So the first part sets up the formula variable called URL.  You can call it anything you like, but the stupid simple way is to always call it URL.

Then that snippet of javascript will execute that URL and refresh whatever page you are on, be it a record or a report. So its simpler to use, because you do not need to have different versions depending on where the button is going to be used. 

As for where you get your Table name, you go to the Table Home page for Projects and then Settings and then Advanced Properties, and its down near the bottom.  The table names gets set when the table is created and it never changes, even though you may rename the table afterwards.  So, for example if you let the table name initially default to say Table 1 (or whoever initially build the app you copied), then that will cause the table DBID to be [_DBID_TABLE_1].  So just carefully copy that and put it in [square brackets].  Be sure not to have a leading space in front of that leading underscore.  
Photo of AZ

AZ

  • 40 Points
replace $URL with $URLONE since you named the variable URLONE. :) Thank you so much! This is easy , I know enough javascript to understand this.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,806 Points 50k badge 2x thumb
Yes, my mistake. I forgot to change that when I did the copy and paste!