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 / Validations in Gallery...
Power Apps
Unanswered

Validations in Gallery and Collections

(0) ShareShare
ReportReport
Posted on by 270

Hi,

 

I have  a gallery with repeating section as shown below

 

JayashreeKrish_0-1629982537275.png

 

 

On my Add&Close button , Display Mode i have this code :

 

If(
CountRows(
Filter(
Gallery_P.AllItems,
IsBlank(P1.Text)
)
) > 0,
DisplayMode.Disabled,
!IsBlank(P7.Text) && !IsMatch(P7.Text,"^[A-Z]{2}$",MatchOptions.Complete),DisplayMode.Disabled,
!IsBlank(P5.Text) && !IsMatch(P5.Text,"^\d{5}$",MatchOptions.Complete),DisplayMode.Disabled,
!IsBlank(P9.Text) && !IsMatch(P9.Text,"^\d{3}-\d{2}-\d{4}$",MatchOptions.Complete),DisplayMode.Disabled,
!IsBlank(P8.Text) && !IsMatch(P8.Text,"^((0[13578]|1[02])\/(0[1-9]|[12][0-9]|3[01])|(0[469]|11)\/(0[1-9]|[12][0-9]|30)|02\/(0[1-9]|[12][0-9]))\/(19|20)\d{2}$",MatchOptions.Complete),DisplayMode.Disabled,
DisplayMode.Edit
)

 

My use case is 

- Border color changes when format is wrong

- Add&close become disabled when fomrat is wrong

 

My issue is ,

- Border color changes wokr fine

- If I enter a  wrong format in row 1add&close button  becomes disabled

- but my add&close button doesnt become disabled when i add a new row with correct format

as shown below

 

JayashreeKrish_1-1629982582905.png

 

This just validates one row and not all rows.

Can someone please help?

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @JayashreeKrish 

    In your scenario you are really only validating one row of your gallery...not all of them.  This is why it is ignoring the row with the error.

     

    What I would recommend is the following:

    - Place a toggle or checkbox control in your gallery row (it is not meant to be visible - you can set Visible to false now or at some point after you have validated this solution).  Let's, for the sake of this explanation, make a toggle and call it tglValid.

    - Now, I'm a big proponent of only doing a formula ONCE and then referring to it.  That way if it ever needs to change, you will only change in one place.  You seem to indicate that you have a validation formula already on the BorderColor of your input controls (I'm assuming on each).  So, assuming that you have formulas on the BorderColor of (for example) the State input of :

        If(!IsBlank(Self.Text) && !IsMatch(Self.Text,"^[A-Z]{2}$"), Red, Black)

    And others like Zip with the same concept:

        If(!IsBlank(Self.Text) && !IsMatch(Self.Text,"^\d{5}$"), Red, Black)

     

    Then with this...set your default property of the above toggle or checkbox to:

        !IsBlank(P1.Text) || P7.BorderColor = Black && P5.BorderColor = Black

    Note: I am only sighting the two controls that I mentioned above...please add the additional controls you have to that formula using the same method.  You'll also notice that I have moved the validation of P1 to this formula.

    Overall, the toggle/checkbox will be true if the row is valid and false if not.

     

    Finally, your DisplayMode property of the Add & Close button would become the following:

    If(
     CountRows(
     Filter(Gallery_P.AllItems, !tglValid.Value)
     ) > 0,
     Disabled,
     Edit
    )

     

    And now you will have what you are looking for.

     

    I hope this is helpful for you.

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 955

#2
11manish Profile Picture

11manish 652

#3
Valantis Profile Picture

Valantis 626

Last 30 days Overall leaderboard