web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to conditionally p...
Power Automate
Answered

How to conditionally pass an empty array?

(0) ShareShare
ReportReport
Posted on by 22,654 Super User 2026 Season 1

Hi All,

 

I'm building a flow to populate a Word template. The template contains some fields that are optional which I want to hide when the value is null.

 

To achieve this I'm trying using to use repeating sections in the template as suggested in this blog: https://joelblogs.co.uk/2021/06/28/microsoft-flow-tip-1-word-templates-and-hiding-empty-repeating-sections/. Basically this says to pass a blank array to a repeating section in the "Populate a Microsoft Word template" action to hide it.

 

This all works fine, but how do I pass an empty array if the value of the item inside the array is null?

 

I have tried the below for the input of the field connected to the repeating section, but apparently the expression is invalid:

 

[

 

 if(
	equals(
		outputs('Get_item')?['body/OptionalField'],
		null
	),
	null,
	"OptionalField": outputs('Get_item')?['body/OptionalField']
 )

 

]

 

Looking forward to your ideas/solutions!

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,830 Most Valuable Professional on at

    Hi @BCBuizer,

     

    Have you tried replacing null by '[]' in the if part of your expression?

     

    Try something like the below:

    if(equals(outputs('Get_item')?['body/OptionalField'],null), '[]', outputs('Get_item')?['body/OptionalField'])

     

    emptyarray_populatetemplate.png

  • Verified answer
    BCBuizer Profile Picture
    22,654 Super User 2026 Season 1 on at

    HI @Expiscornovus ,

     

    In my case I have a text content control inside the repeating section, hence the need to pass a key-value pair. The reason for this is that I don't want the section to even show up in the populated document.

     

    Using your expression I got a blank array in case the value was blank, but I couldn't get the populated array to return correctly:

    if(
    	equals(
    		outputs('Get_item')?['body/OptionalField'],
    		null
    	), 
    	'[]', 
    	'[{"OptionalField": outputs('Get_item')?['body/OptionalField']}]'
    )

     

    I ended up using a Filter Array function to filter out the item in case the value was null and use the outputs to populate the template:

    BCBuizer_0-1689946106890.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 552

#2
Valantis Profile Picture

Valantis 388

#3
11manish Profile Picture

11manish 375

Last 30 days Overall leaderboard