cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Unkn0wn
Helper I
Helper I

Gallery Validations

Hi Community

 

I'm having a galleries as shown below

Unkn0wn_1-1625639275177.png

 

I'm using below patch to submit the galleries data

 

Concurrent(
    ForAll(
        Gal_Students.AllItems,
        Patch(
            Students,
            {
                Student_Name: Ip_StudentName.text,
                Parent_Name: IP_ParentName.text,
                DOJ: IP_DOJ.SelectedDate,
                Mobile: IP_Mob.text,
                Email:Ip_Email.text
            }
        )
    ),
    ForAll(
        Gal_Prof.AllItems,
        Patch(
            Professors,
             {
                Professor_Name: Ip_ProfessorName.text,
                Education: IP_Edu.text,
                DOJ: IP_DOJ_1.SelectedDate,
                Mobile: IP_Mob_1.text,
                Email:Ip_Email_1.text
            }
        )
    )
);

 

and i want to perform some basic validations like email & mobile number validation, and doj <= today(). the problem here is how can i validate the gallery items as we do in forms as shown below and prevent the submit button to patch the data to the datasource and highlight the errors ?

Unkn0wn_2-1625639765278.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Maybe you could use If() Formulas in the OnSelect Property of your submit button?

If yout create a local collection before patching the data you could validate the data set.

 

Like:


Concurrent(
    ForAll(
        Gal_Students.AllItems,
        Patch(
            colStudents,
            {
                Student_Name: Ip_StudentName.text,
                Parent_Name: IP_ParentName.text,
                DOJ: IP_DOJ.SelectedDate,
                Mobile: IP_Mob.text,
                Email:Ip_Email.text
            }
        )
    ),
    ForAll(
        Gal_Prof.AllItems,
        Patch(
            colProfessors,
             {
                Professor_Name: Ip_ProfessorName.text,
                Education: IP_Edu.text,
                DOJ: IP_DOJ_1.SelectedDate,
                Mobile: IP_Mob_1.text,
                Email:Ip_Email_1.text
            }
        )
    )
);

If(Blank() in colStudents.Student_Name || Blank() in colProfessors.Professor_Name;
"Your Validation Message / Action);

Patch(Professors;colProfessors;
Patch(Stundents;colStudents)
)

 

 

View solution in original post

6 REPLIES 6
KimBim
Advocate I
Advocate I

Hey @Unkn0wn,

Unfortunately i don't think there is any "build in" validation capability in galleries.

Matthew Devaney did a great blog on simple data validation. I would highly recommend this to you 🙂
https://matthewdevaney.com/data-validation-for-power-apps-forms/

 

Once build the validations you can put this kind of function on you Submit button DisplayMode Property:

If( YourIconName.Icon = Icon.Cancel; DisplayMode.Disabled;DisplayMode.Edit)
The same you could do with your button text or another property 🙂

 

Hope this helps! We use this validation method a lot

CNT
Super User
Super User

@Unkn0wn You can use the IsMatch function to do the validations, https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-ismatch#predefined-p...

 

To show the error messages, you can do it in the OnChange() of the TextBox to give immediate validation and also use the SetFocus() to retain focus in the same field till a valid input is typed.

Unkn0wn
Helper I
Helper I

Hi @CNT 

thanks for the quick reply. validating the error messages based onChange() property is giving validation. but i want to perform late validation i.e. onclick of submit button (which we usually observe on submitform)

Unkn0wn
Helper I
Helper I

Hi @KimBim 

thanks i'll give it a try. is there a way where we can enable the submit button always rather than applying this kind of validations If( YourIconName.Icon = Icon.Cancel; DisplayMode.Disabled;DisplayMode.Edit) on display mode. and onclick of submit to showcase the errors

Maybe you could use If() Formulas in the OnSelect Property of your submit button?

If yout create a local collection before patching the data you could validate the data set.

 

Like:


Concurrent(
    ForAll(
        Gal_Students.AllItems,
        Patch(
            colStudents,
            {
                Student_Name: Ip_StudentName.text,
                Parent_Name: IP_ParentName.text,
                DOJ: IP_DOJ.SelectedDate,
                Mobile: IP_Mob.text,
                Email:Ip_Email.text
            }
        )
    ),
    ForAll(
        Gal_Prof.AllItems,
        Patch(
            colProfessors,
             {
                Professor_Name: Ip_ProfessorName.text,
                Education: IP_Edu.text,
                DOJ: IP_DOJ_1.SelectedDate,
                Mobile: IP_Mob_1.text,
                Email:Ip_Email_1.text
            }
        )
    )
);

If(Blank() in colStudents.Student_Name || Blank() in colProfessors.Professor_Name;
"Your Validation Message / Action);

Patch(Professors;colProfessors;
Patch(Stundents;colStudents)
)

 

 

View solution in original post

v-albai-msft
Community Support
Community Support

Hi @Unkn0wn ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

If above reply is helpful to you, you can mark it as a solution. This will benefit other community members who stuck with the same question.

Best regards,

Allen

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,249)