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 / Checking for empty fie...
Power Apps
Answered

Checking for empty field values in records in gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a Gallery that displays 1 or more records based on user selection.  The record(s) contain multiple fields, of which I need to verify that 2 fields (Asset ID, VIN) in all records displayed in the gallery contain values when the user presses a save button.  I have the following code in place and it works, but I'm curious if there is a more efficent way to do this, as it feels a bit clunky to me (creating a collection to hold the rowcounts of blank records).

 

Here is the screen:

2019-09-19 10_06_41-Equipment Requester Admin - Saved (Unpublished) - PowerApps.png

 

Here is the code:

Clear(ValidateCollection);

//Create a new collection to check if all required fields are populated
ForAll(
 EquipmentGallery_DetailsScreen.AllItems,
 If(
 IsBlank(AssetIDTextInput_DetailsScreen.Text) || IsBlank(VINTextboxInput_DetailsScreen.Text),
 Collect(
 ValidateCollection,
 {RequestID: RequestIDDataLabel_DetailsScreen.Text}
 )
 )
);
//If we have rows, then we have blank required field entries
If(
 CountRows(EquipmentGallery_DetailsScreen.AllItems) <> 0,
 "Save code goes here", 
UpdateContext({conValidationErr: true, conValidationMessage: "!"}) )


I use the context variable to drive user feedback for the required fields.  

 

Categories:
I have the same question (0)
  • Verified answer
    wyotim Profile Picture
    2,545 on at

    Hey @Anonymous, here's the way I would go at it. In the EquipmentGallery_DetailsScreen gallery I would hide (Visible property = false) a text label with the following:

     

    IsBlank(AssetIDTextInput_DetailsScreen.Text) || IsBlank(VINTextboxInput_DetailsScreen.Text)

    which will produce a boolean (true/false) value for each row of the gallery (true if one or more of those text inputs are blank, false otherwise). Next, I would count how many of those text labels are true like so:

    CountIf(EquipmentGallery_DetailsScreen.AllItems.lblBlankItems, lblBlankItems.Text = "true")

     where lblBlankItems is the name of the aforementioned text label. Note that the "true" is a text value and in double-quotes as we are checking the label's text, not for a true/false value in the typical sense. If this count is equal to zero, all of those fields have an entry. If not, one or more is missing an entry.

     

    If you did something like :

    If(
     CountIf(EquipmentGallery_DetailsScreen.AllItems.lblBlankItems, lblBlankItems.Text = "true") = 0,
     "Save code goes here", 
     UpdateContext({conValidationErr: true, conValidationMessage: "!"})
    )

    I think you could cut out the entire collection business altogether.

     

    Let me know if that works for you or not; I'd be happy to follow up if needed!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Beautiful!  That was a brilliant idea and way less clunky than what I had.  Thank you!

  • wyotim Profile Picture
    2,545 on at

    You are most welcome! Happy to be able to help!

  • abc 123 Profile Picture
    789 Moderator on at

    Worked great, Thanks!

  • Frown Profile Picture
    46 on at

    It didn't work for me, but it taught me a new technique that will be valuable in future. Thank you!

  • tu22 Profile Picture
    44 on at

    tu22_0-1669291755705.png

    I am try to check for empty rows within the gallery and count the empty rows but all the rows are empty but it shows false. what am i missing?

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 Apps

#1
Vish WR Profile Picture

Vish WR 633

#2
11manish Profile Picture

11manish 588

#3
Valantis Profile Picture

Valantis 457

Last 30 days Overall leaderboard