cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NigelP Post Prodigy
Post Prodigy

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
Community Support

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 Post Prodigy
Post Prodigy

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,451)