Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Validation Before Submission

(0) ShareShare
ReportReport
Posted on by

I inherited a Nintex form that has a lot of different validations based on different conditions.
None of the fields in the SharePoint list are set to required but the data cards are set to required.
When I run my patch, it still patches to SharePoint even though I have empty required fields.
With that being said I am looking at putting all of the conditions in a button that will either be visible or not if the conditions are not met before it navigates to the popup patch button.
So here is my first condition I have a rich text box that can't be empty when a yes/no choice is set to "Yes"
Here is the logic and its not working as I had hoped.

If(
    Len(RichTextEditor1.HtmlText = 0) && (DataCardValue36.Value = false),
    false,
    true
) || If(
    Len(RichTextEditor1.HtmlText = 0) && (DataCardValue36.Value = true),
    false,
    true
)
I am sure its my inexperience in writing this that's causing my headache.
Categories:
  • ChrisL58 Profile Picture
    ChrisL58 on at
    Re: Validation Before Submission

    Here is the same but with added choice fields.

    !(Len(RichTextEditor1.HtmlText) = 0 && DataCardValue36.Value = true) || !(Len(RichTextEditor1.HtmlText) > 0 && DataCardValue36.Value = false) || !IsBlank(cboFundingTeamColleague.Selected.DisplayName) || If(
        DataCardValue25.Selected.Value = "Yes" && DataCardValue28.Selected.Value = "Yes" && DataCardValue23.Selected.Value = "Yes" && DataCardValue26.Selected.Value = "Yes" && DataCardValue7.Selected.Value = "Yes" && DataCardValue24.Selected.Value = "Yes",
        true,
        false
    )
    When evaluating the form, one of the fields is set to "No" but yet the Save Edit button still shows.
    ChrisL58_0-1716230642870.png

     

  • ChrisL58 Profile Picture
    ChrisL58 on at
    Re: Validation Before Submission

    Hi Warren,
    Sorry there are two separate but related issues dealing with how to submit a form.
    The form is actually continuous and controlled with tabs.

    ChrisL58_0-1716218629912.png

    ChrisL58_2-1716218824651.png

    The red oval is the "Save Edit" button that can only show if all conditions are met.
    The top tabs show each page/form in the process.
    The first page/form is required.
    Once submitted a person from the funding team will evaluate the first page input and then make their selections on the next two tabs "Funding Team" and "Next Steps", which is what you assisted me with.
    Patch doesn't allow Validation and the Errors function only captures errors when the underlying SharePoint list is being used by Power Apps and not any other controls that will be required in the future when edits to the process are made.

  • ChrisL58 Profile Picture
    ChrisL58 on at
    Re: Validation Before Submission

    Hi Warren,
    You have it.
    I wound up with this: 

    !(Len(RichTextEditor1.HtmlText) = 0) && (DataCardValue36.Value = true) || !(Len(RichTextEditor1.HtmlText) > 0) && (DataCardValue36.Value = false)
    <>0 would work as well, right?
  • WarrenBelz Profile Picture
    WarrenBelz 145,636 on at
    Re: Validation Before Submission

    @ChrisL58 ,

    Sorry I am lost with your latest post - you simply asked about basing visibility on the state of two different controls. I will be offline now due to time one. @Amik - I see you responded earlier - you might want to have a go at this.

  • ChrisL58 Profile Picture
    ChrisL58 on at
    Re: Validation Before Submission

    Hello and thank you for your response.
    That wont work as I am using one form for both New and Edit.
    Also, there are fields on both new and edit that are required based on what part of the form entry process is occurring. For example, the form has some fields that are required in the beginning of the process and then after the form is submitted, the second set of controls (some are required) are then updated and then the form is submitted again. 

  • WarrenBelz Profile Picture
    WarrenBelz 145,636 on at
    Re: Validation Before Submission

    Hi @ChrisL58 

    Just the opposite

    Len(RichTextEditor1.HtmlText) > 0 && DataCardValue36.Value

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • ChrisL58 Profile Picture
    ChrisL58 on at
    Re: Validation Before Submission
    The Save Edit button shows when both the richtexteditor1 is empty and datacardvalue36 is false. I want the Save Edit button to show when the richtexteditor1 box contains a value and when the datacardvalue36 toggle is true .
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,636 on at
    Re: Validation Before Submission

    Hi @ChrisL58 ,

    If you simply want to display the button when the input is valid (excluding the button being true with the HTML Box empty)

    !(Len(RichTextEditor1.HtmlText) = 0 && DataCardValue36.Value)

    but I suspect you have a few more conditions to add to this.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Ami K Profile Picture
    Ami K 15,655 on at
    Re: Validation Before Submission

    @ChrisL58 - the SubmitForm function will validate the Required property of each DataCard prior to executing the save operation to your data source. The Patch function does not check whether the DataCard properties are valid, it will simply execute the save operation onto the fields that you specify.

     

    Unless you have a specific reason to use Patch, I would suggest using the SubmitForm function.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,636

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,942

Leaderboard