8 Replies Latest reply on May 24, 2016 10:39 AM by creditunion123

    app.addToolButton code

    creditunion123 Level 1

      I have a form that has specific print parameters based on user input at the beginning of the form

       

      My question is two-fold

      The code below (just the this.print stuff)  works great if I place it it a button, but that button placement is fixed and staff may miss it if they scroll past page 1

      I tried the code in the Set Document actions - Document Will Print - but it did not work

       

      I have tried to create a Tool button (full code below)

       

      It kinda works and kinda not.  It creates the button and that button is available no matter what page the staff is on - Great but it is ugly.  Is there a way to make it look better that just that javascript window or better yet is there a way to make just a normal button float with scrolling or be anchored on the side like the toolButton  - if not NOT BIG DEAL

       

      My larger problem is this.

      When my form opens it comes up saying document is trying to print do you want to allow - I hit NO.  It then creates my tool button.  Which when I click - then prints

      I dont want to have it ask if I want it to print  I only want this to occur IF I click

       

      I know part of the issue is the function at the beginning but I am not sure how to fix

      I have to create the toolbar button but how do I get the function to only work when that tool Bar is clicked since the code is at the document level

       

      I just want a way to have the form print and not have to have staff "think"

       

      // what parameter am I looking for
      var email = this.getField("FormValues.emailAddress_0").value

      // create the function I want executed when pressed

       

      function() cButtJS {
      if (email !=""){
      this.print({
      bUI: false,
      bSilent: true,
      bShrinkToFit: true,
      nStart: 0,
      nEnd: 2
      });
      }
      else if (email ==""){
      this.print({
      bUI: false,
      bSilent: true,
      bShrinkToFit: true,
      nStart: 0,
      nEnd: 15
      });
      }
      }

      // enable button

      app.addToolButton({cName:"PRINT CSHARES", cLabel:"CLICK HERE to Print Document", cTooltext:"", cExec:"cButtJS"});