cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted
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
Highlighted
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.

Highlighted
Frequent Visitor

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. 

Highlighted
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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,284)