Discussions

Expand all | Collapse all

Open Print dialog when clicking "print exact form" button

  • 1.  Open Print dialog when clicking "print exact form" button

    Posted 09-24-2020 09:44
    Ok, I've gotten this to work with regular forms before, but I cannot get this to work with an exact form. I have a button to open the form in a new window and, on regular forms, it automatically fires the print dialog. However, trying the same syntax does not work with the exact forms button. Here is what my code looks like:

    URLRoot() & "db/" & Dbid() & "?a=dbpage&pagename=" & URLEncode("Work Order Cover Sheet .html") & "&clist=a&apptoken=XXX&rid=" & "?a=printr&rid=" & [Record ID#]​


    Of course I've XXX'd out the app token above. (it doesn't even require them, but this button was auto-generated) Any ideas why this won't work?



    ------------------------------
    Thanks,
    Chris Newsome
    ------------------------------


  • 2.  RE: Open Print dialog when clicking "print exact form" button

    Posted 09-24-2020 17:01
    The only way I managed to get the print dialog to auto-open for an exact form that I created was, I believe, to embed it into the html of the page after the initial upload.

    Unfortunately, this would tell chrome to generate a printable version of the page while it was still processing - leading to a page full of field tags (~x~) instead of the data.  

    It was about a year or so ago that I left well-enough alone on it, but it couldn't hurt to explore it again.  I'll let you know what I find out.

    ------------------------------
    Brad Lemke
    ------------------------------



  • 3.  RE: Open Print dialog when clicking "print exact form" button

    Posted 09-24-2020 18:21
    Insert this code into your exact form anywhere in the <body> section, possibly best results at the very bottom:
    <script>
    setTimeout(function() {this.print()},3000);
    </script>

    This will call up the print function after 3,000ms (3 seconds).  You can increase or decrease that number as needed if there are a bunch of images/tables that need to be generated before calling the print function.

    ------------------------------
    Brad Lemke
    ------------------------------