Announcement
Collapse
No announcement yet.
Printing to PDF
Collapse
X
-
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"
Code:ifThenElse( addressStreet, folderName = string\concatenate(addressStreet, ", ", addressCity, " ", addressState, " ", addressPostalCode," (", propertyID, ")"), folderName = string\concatenate(addressCity, " ", addressState, " ", addressPostalCode," (", propertyID, ")") );
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 esforim; 07-15-2020, 12:44 AM.
-
You need to use ifThen.
Code:folderName = null; ifThen( addressStreet, folderName = string\concatenate(addressStreet, ", ", addressCity) );
- Likes 1
Leave a comment:
-
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 https://docs.espocrm.com/administrat...ula/#operators
Leave a comment:
-
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.
Formula:
Code:myCustomBoolField = string\contains(fieldName, 'needle');
- Likes 1
Leave a comment:
-
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!
EXAMPLE
Code:{{#if fieldName == "example" }} "set this text" {{/if}}
Leave a comment:
-
Printing to PDF
Is it possible to only print a filed to PDF, if it is not empty?Tags: None
Leave a comment: