cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NigelP
Level 8

Validating a New Form (Form Mode = FormMode.New)

Hi

 

Whilst there is a lot of documentation on validating forms when they are in Edit Mode, there does not seem to be alot of documentation about validating a form when in New Mode.

 

I  would like to make sure all of the fields marked as "Required" have actually got something in them and the entered value is acually the right type (integer, string etc).  Each card on the form has got "Required" set to true.

 

I would like to validate the form before I submit it. (Form.Valid does not seem to work for forms in Form.Mode = FormMode.New) 

 

Have i missed something ?

 

Regards

 

Nigel

2 REPLIES 2
Community Support Team
Community Support Team

Re: Validating a New Form (Form Mode = FormMode.New)

Hi @NigelP ,

Could you please share a bit more about your scenario?

Do you want to validate a New Form using the Form.Valid formula?

 

Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentioned. The Form.Valid formula works well with All Required fields within my New Form. On my side, I set the OnSelect property of the "Submit" button to following:

If(
EditForm1.Valid,
SubmitForm(EditForm1),
Notify("There are some invalid values in your Edit form", NotificationType.Error)
)

 

Please make sure you have set the Required property to true for all fields in your Edit form, and provide values for these Required fields when you test the Form.Valid formula.

 

Please consider take a try to re-create a new app based on your data source, set the OnSelect property of the "Submit" button to following:

If(
    YourEditForm.Valid, 
    SubmitForm(YourEditForm), 
    Notify("There are some invalid values in your Edit form", NotificationType.Error)
)

 

In addition, as an alternative solution, please also take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

If(
   !IsBlank(DataCardValue1.Text) && !IsBlank(DataCardValue2.Text) && !IsBlank(DataCardValue3.Selected.Value) && ... ,
   SubmitForm(YourEditForm),
   Notify("There are some invalid values in your Edit form", NotificationType.Error)
)

Note: The DataCardValue1, DataCardValue2, DataCardValue3, ... represents the Input controls in your Edit form.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
NigelP
Level 8

Re: Validating a New Form (Form Mode = FormMode.New)

Hi @v-xida-msft 

 

I will try and explain more what I am going to achieve....

 

If I have a form which is in Edit Mode, then the Valid Property of the Form continuously updates (true / False / True etc) as I update fields.

 

If I take the same form and put it into New Mode  (New_Form(MyForm)) the Valid proprty does not continuously update as I enter the fields.

 

I can reproduce this behaviour by inserting a Label above the form and setting its Text property to MyForm.Valid and observing it when the form is in Edit mode and I am changing fields and then again when it is in New Mode.

 

Regards

 

Nigel

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,551)