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

Notifications

Announcements

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,505 Super User 2025 Season 2

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,195 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,505 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard