I have a flow that generates Word documents. The word template contains home addresses of the recipients made up of 4 fields that come from an Excel file. Street and House Number", "Second Address Line", "District" and "Postal Code".
Some of the 4 address field data columns may contain null values causing gaps in the address fields in the word document.
Date
Votes
1 comment
-
Official comment You can use conditional expressions and control characters (in this case line breaks) to achieve a properly formatted address section.
Take this JSON data for example (which would come from your Excel):{
"StreetAndHouseNumber": "123 Main St",
"SecondAddressLine": "",
"District": "Central",
"PostalCode": "12345"
}Set-up your template as follows:Take this JSON data for example (which would come from your Excel):{
"StreetAndHouseNumber": "123 Main St",
"SecondAddressLine": "",
"District": "Central",
"PostalCode": "12345"
}Set-up your template as follows:<<if [StreetAndHouseNumber != ""]>><<[StreetAndHouseNumber]>> <<[ControlChar.LineBreak]>><</if>><<if [SecondAddressLine != ""]>><<[SecondAddressLine]>> <<[ControlChar.LineBreak]>><</if>><<if [District != ""]>><<[District]>> <<[ControlChar.LineBreak]>><</if>><<if [PostalCode != ""]>><<[PostalCode]>> <<[ControlChar.LineBreak]>><</if>>
Set your JSON parse mode to strict so that your numeric Postal code is not converted to an integer and the != "" checks works:
This will generate the following output (i.e. no line space for the missing second address line):
Please sign in to leave a comment.