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 Apps / Collection - collect o...
Power Apps
Answered

Collection - collect only non-blank fields or remove blank fields?

(0) ShareShare
ReportReport
Posted on by 10

Hi, 

I am building an App with user interaction and integration with a third-party system via http-request. I collect all the data in big collection at the end, convert it to JSON and pass it to my Flow. The basic process is working, but I am now stuck on one particular issue: 

The user input can vary, but the third-party interface only accepts populated fields. I have the situation that I have to have e.g. multiple address line inputs, but they are not always filled out (based on the use case). I can't simply pass on all of the fields, since the interface then rejects the request because fields are empty/null (both is not accepted). Example: 

addressline2_null.png

 

In such a case, I would have to leave out the second address line (AdressLine2) completely in the request/collection:

addressline2_removed.png

So for me that means removing it from my collection or not collecting it at all at runtime, if the field is blank. My collection would have to be dynamic with regards to the columns, based on which fields are filled in by the user. 

How can I achieve this seemingly easy task? 

Thanks!

 

Categories:
  • Verified answer
    timl Profile Picture
    37,287 Super User 2026 Season 2 on at

    @MathiasM 

    I'm working on the assumption that your collection can contain multiple rows - some of which will have a addressLine2 value, and others not.

    On the basis that you call the JSON function to generate the JSON, there's no way to conditionally exclude fields that are null.

    A possible (although non-elegant) approach to this is generate the JSON and to strip out those fields that are null.

    Substitute(
     yourJSON,
     """addressLine2"": null,",
     ""
    )
    

     

    You can adapt this include other possibile null fields.

    Substitute(
     Substitute(
     yourJSON,
     """addressLine2"": null,",
     ""
     ),
     """cityName"": null,",
     ""
    )
  • MathiasM Profile Picture
    10 on at

    Thank you both for the replies! 

    @Ali_SZ_365 This solution would work for a simpler construct, but my final JSON that I pass on has a depth of 4 levels and various sub-arrays, so constructing this from scratch via variable seems not feasible.

     

    @timl My collection indeed only contains one row (by design) - but it has various sub-tables with multiple rows. Your proposal works like a charm, although it is not elegant as you point out. But for me that is a viable solution. Thank you so much! 

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard