cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Rick4him
Level: Powered On

How do you make a required column issue an error before submit form or trap afterwards

Example of what does not work.  A column is set to required (actually not the column but the encompassing datacard).  The code below is executed via a button without filling the required column.

 

SubmitForm(form_Edit);
UpdateContext(
    {
        EditRecord: First(
            Filter(
                '[dbo].[TestSource]',
                TestIndex = _CurTestIndex
            )
        )
    }
);
If(
    IsEmpty(
        Errors (
            '[dbo].[TestSource]',
            EditRecord
        )
    ),
    Back()  
)

 

The program actually executed the "Back()" function ignoring there is an error. I have tried it with and and without an EditRecord.  What does happen on the very first occurence (non on subsequent), the error shows on the page returned to (from back()) (see attached ErrorOnPriorPage.jpg).  If you show the submited form again, then you will see the column is highlighted in error that it is required (see ErrorOnFormPage.jpg).

 

The behavior I want is to stop the page from submitting when there is a required column.  Ideally, testing for the error on the page before submitting?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: How do you make a required column issue an error before submit form or trap afterwards

Move your Back() command to the OnSuccess property of the form. That way, if the Submit fails, you are not moved to a different screen.

View solution in original post

3 REPLIES 3
Super User
Super User

Re: How do you make a required column issue an error before submit form or trap afterwards

I take the approach of setting the Display property of the Submit button to Disabled unless all the required fields are completed - check using IsEmpty(MyTextField.Text)

That way you don't need to worry about an error where a user submits an incomplete record.

Rick4him
Level: Powered On

Re: How do you make a required column issue an error before submit form or trap afterwards

Yes, I have tried that but what is the purpose to have a required data card that does not give you the message it was not filled until after you leave the page as you cannot tell it was required on the page, I wonder if the developer actually tested the functionality using a form.  I am going toward changing submit forms to patch, a lot of extra work but does seem to give you finer control. 

Super User
Super User

Re: How do you make a required column issue an error before submit form or trap afterwards

Move your Back() command to the OnSuccess property of the form. That way, if the Submit fails, you are not moved to a different screen.

View solution in original post

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 (5,590)