Skip to main content
Question

Save and Print a Form

  • September 20, 2021
  • 0 replies
  • 185 views

Hello,
I am making a button that will go on a form that will save the data then bring up the print menu. The issue I am running into is that if I add a button that simply says print this record it doesn't work because it is a form and hasn't been saved into a record yet. So I need a button that will save then print. The next thing I tried was to save by redirecting then trying to print but I cannot get that to work because the URL code calls the active RID which is gone once the page has redirected. I am not completely confident in my button/url coding abilities so I could be fundamentally wrong about what is going on but I would appreciate any help to point me in the right direction. 

My code for a formula URL that tries to just print the form:

URLRoot() & "db/" & Dbid() & "?a=printr&dfid=11&rid=" & [Record ID#]
//I don't think the RID exists until the form is saved 

Then my code to redirect the user to save the form to a record:

//formatting visuals of button
var text bgcolor = "#34A853";
var text txtcolor = "white";
var text style = "style=\"text-decoration: none; background:" & $bgcolor & "; border-radius: 5px; padding: 8px 20px; color: " & $txtcolor & "; display: inline-block; font: normal 700 24px/1 \"Calibri\", sans-serif; text-align: center; text-shadow: none;";

//Inner workings of button
var text url =

URLRoot() & "db/" & [_DBID_Project] & "?a=printr&dfid=11&rid=" &[Record ID#]
& "&apptoken=uwi4fb9cj4szcdzjnfxd5xz3te"
& "&rdr=" & URLEncode("https://divisionsinc.quickbase.com/db/brjciz2i6?a=td");

"<a " & $style & " href=\"" & $url & "\">Save and Print</a>"

I couldn't get either of these to work so any help is appreciated. Thanks in Advance!


------------------------------
Hank Halverson
------------------------------
This topic has been closed for replies.

MarkShnierYou
Forum|alt.badge.img+24
I doubt that this can be done in one click because the Record ID# does not exists until the record is saved.

------------------------------
Mark Shnier (YQC)
mark.shnier@gmail.com
------------------------------

I found this in the quickbase code samples, may work for you but I don't know for certain. 

var text rid = 
    If([Record ID#]>0,
        ToText([Record ID#]), // Record ID already exists
        "%%rid%%" // New record, no Record ID exists yet
    )
;
var text url = URLRoot() & "db/" & Dbid() & "?a=er&rid=" & $rid;

"<a class='Vibrant Primary SaveBeforeNavigating' data-replaceRid=true href='" & $url & "'>Save & Keep Working - Rich Text</a>"

In your case, you would need to save the record prior to pulling up the print functionality. This would save your record, and then you can use the rdr= to redirect you to the print version. 

Link to the example: https://resources.quickbase.com/db/bq8mgh24g?a=dr&rid=3206

------------------------------
Ursula Llaveria
------------------------------