No announcement yet.

Printing to PDF

  • Filter
  • Time
  • Show
Clear All
new posts

  • Printing to PDF

    Is it possible to only print a filed to PDF, if it is not empty?

  • #2

    {{#if fieldName}} {{fieldName}} ​​​​​​​{{/if}}


    • #3
      Thank you! Now I understand what I was doing wrong


      • #4
        Is it also possible to check whether a field contains a certain character or word? I'm stuck with the depending on the output in PDF!

        {{#if fieldName == "example" }} "set this text" {{/if}}


        • #5
          You can create a custom field of boolean type (set it read-only), and use formula (before-update script) to set true or false depending on whether your field contains word.

          myCustomBoolField = string\contains(fieldName, 'needle');
          Then when you print PDF you can check this boolean field.


          • #6
            Does this also work for formula? For example I don't want a "comma" to show up this if the field addressStreet is empty.

            Original formula
            folderName=string\concatenate(addressStreet, ", ", addressCity");

            How would this become formula?

            None of the Operators seem to match for blank


            • #7
              You need to use ifThen.

              folderName = null;
                folderName = string\concatenate(addressStreet, ", ", addressCity)


              • espcrm
                espcrm commented
                Editing a comment
                folderName = null;

                I believe this code is to clear out any existing data in folderName, but is there any "programmer" secret behind the reason to doing that? Formula work without it.

              • yuri
                yuri commented
                Editing a comment
                If your addressStreet will change its value to empty, then folderName will be erased too.

            • #8
              Print2PDF PDF_ ifThenElse code

              Thank you yurikuzn.

              Please ignore following paragraph if you just want the code. These are just my insight and input in learning.

              It took a while to get it to work the way I wanted, the above code will leave your folder name blank (null/none) if street is missing. This isn't what I truly wanted. After thinking about it a little I finally understood something. The way it is formatted make it look easier to the eyes so I didn't understand that at first. Then I remembered that were was another "if" code and after trying that I got it to work as I wanted it to. Of course it does have it weakness at the moment but I suppose the secret to "if blank" is not to give it any condition(?), hence it just a ", comma" straight after addressStreet.

              I suppose next issue is, should I breakdown the paragraph further or leave it long row. Secondly is, what if the State or Postcode were missing, is there a better way to chain "if" code or a secondary if code should use instead.

              Anyway here is my final code with the full data and simplified data for a "folder/file name"

              folderName = string\concatenate(addressStreet, ", ", addressCity, " ", addressState, " ", addressPostalCode," (", propertyID, ")"),
              folderName = string\concatenate(addressCity, " ", addressState, " ", addressPostalCode," (", propertyID, ")")
              (Used: to generator fake test data).

              847 Liberty Ave
              Dorchester Center MA 02124

              Result is as follow if there was an Street address:

              847 Liberty Ave, Dorchester Center MA 02124 (ID123)

              Result is as follow if there was no treet address:
              Dorchester Center MA 02124 (ID123)

              Result if you don't have this formula and just use a string\concatenate for an address without Street name. Look very funny.
              , Dorchester Center MA 02124 (ID123)
              Last edited by espcrm; 07-15-2020, 12:44 AM.