cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ken_Short
Frequent Visitor

How to remove second address line if empty

Using the "populate ms word template" to create a mailing address in a word document from a JotForm submission. Using the Plain Text Content Control within my MS Word template.

 

With two address lines, things are good. When there is only one, how do I get the blank line that would be used for the second address line, to disappear, and present the address properly

 

Like this:

FirstName LastName

Street1

Tampa FL 33620

 

not like this:

 

FirstName LastName

Address1

 

Tampa FL 33620

 

Data is coming in via JotForm. Each address piece is a different field.

 

address.JPG

 

I've tried using {IF statements, etc.. but since these are not mail merge fields, none of that has been helpful. I tried setting it as a bookmark, and then using IF {REF Bookmark} "" , but only received an error that the condition wasn't found.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @Ken_Short ,

 

It seems that you want to remove a control if Flow does not fill the control with any values.

I think Flow does not support this function. The work of Populate MS Word template is to fill the corresponding values for the configured controls. It does not support setting or editing the controls stored in the template.

Maybe you could solve your problem by setting up Word Online Templates, please consider submitting your question here to see if you can get the right method:
https://techcommunity.microsoft.com/t5/Office-365/Word-online-Templates/m-p/78748

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-bacao-msft
Community Support
Community Support

 

Hi @Ken_Short ,

 

It seems that you want to remove a control if Flow does not fill the control with any values.

I think Flow does not support this function. The work of Populate MS Word template is to fill the corresponding values for the configured controls. It does not support setting or editing the controls stored in the template.

Maybe you could solve your problem by setting up Word Online Templates, please consider submitting your question here to see if you can get the right method:
https://techcommunity.microsoft.com/t5/Office-365/Word-online-Templates/m-p/78748

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SJNBham
Advocate II
Advocate II

@Ken_Short - there's a way to do this by using an array variable in Power Automate and a repeating content control in a Word template.

 

  1. Create two columns in your SharePoint list: Street1 and Street2
  2. Create a flow and Initialize an Array variable like varStreetAddress
  3. Use a Condition action to check if a value in your Street2 column is not equal to null
  4. If Street2 isn't null, use two Append to Array Variable actions with the following set as the values:
    1. Append to Array Variable first action: Name = varStreetAddress;  Value = {"Street":"Street1 dynamic value"}
    2. Append to Array Variable second action: Name = varStreetAddress; Value = {"Street":"Street2 dynamic value"}
  5. If Street2 is null, then use a single Append to Array Variable actions with the following set as the value:
    1. Append to Array Variable first action: Name = varStreetAddress; Value = {"Street":"Street1 dynamic value"}
  6. Edit your Word template and add a plain text control where you want the Street address to appear. Set the Content Control Property Title field to Street.
  7. Select the entire row where the plain text control appears and insert a Repeating Section Content Control. Set its Content Control Property Title field to Street Addresses. This can be kind of tricky to select the repeating control once it's created, but you'll know when you have because the Title property will be blank until you type in Street Addresses. You'll also need to make sure to select the who line or you'll get an error when trying to insert the repeating control.
  8. Save your Word template and upload it to a SharePoint document library.
  9. Edit your workflow again and add a Populate a Microsoft Word template action. This action will give you the option to point to the site, library, and template you uploaded in step 8. 
  10. You should see an option to set the value for Street Addresses. Select the "Switch to input entire array" option in the top right corner of the Street Addresses field. 
  11. Select your varStreetAddress as the value after switching to the entire array option

This will suppress the extra blank Street2 line in your Word document if it doesn't have a value in that column. 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (4,371)