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

Required Fields (Not using forms)

Good day, PA community.

I need to have a few input boxes be required before the submission of a patch to a SQL DB.  What seems to be a straightforward process is proving to be more difficult than I had originally thought.  I am returning a message when the 3 input boxes are left blank but it seems as though my 'Else' statement doesn't trigger once all required fields are populated.  Below is a snippet of the code I have written.  I've tried several different methods to no avail.

 

If(
    IsBlank(inpPremium),
    UpdateContext({varRequiredFields: true});
    IsBlank(inpCollateral),
    UpdateContext({varRequiredFields: true});
    IsBlank('inpCheck#'),
    UpdateContext({varRequiredFields: true}),
    UpdateContext({varRequiredFields: false});
    UpdateContext(
        {
            RecordCount: CountIf(
                '[dbo].[ARParameters]',
                Account = drpAccount.Selected.Result,
                GroupNumber = drpGroupNumber.Selected.Result,
                PolicyYear = drpPolicyYear.Selected.Result
            )
        }
    );
    If(
        RecordCount > 0,
        UpdateContext({varShowDuplicateRecord: true}),
        Patch(
            '[dbo].[ARParameters]',
            Defaults('[dbo].[ARParameters]'),
            {
                Account: drpAccount.Selected.Result,
                GroupNumber: drpGroupNumber.Selected.Result,
                PolicyYear: drpPolicyYear.Selected.Result,
                TotalReceipt: Value(dspTotalReceipt.Text),
                PremiumAmount: Value(inpPremium.Text),
                CollateralAmount: Value(inpCollateral.Text),
                PostDate: inpPostDate.SelectedDate,
                CheckNumber: Value(inpCheckNum.Text),
                SubmittedBy: User().FullName,
                Approved: "No"
            }
        )
    )
);
UpdateContext({varShowSuccess: true});

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User III
Dual Super User III

I normally do this by setting a variable to be true only if all three values are set.  Then simply use that value to disable the submit button using the Display mode if they aren't all filled in.  If you get more than two or three you can also use the Onchange event to increment/decrement a counter to see if all the values have been filled in.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

5 REPLIES 5
Dual Super User III
Dual Super User III

I normally do this by setting a variable to be true only if all three values are set.  Then simply use that value to disable the submit button using the Display mode if they aren't all filled in.  If you get more than two or three you can also use the Onchange event to increment/decrement a counter to see if all the values have been filled in.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

I hadn't thought of using the display mode of the button.  That's actually a great idea.  I'll give that a try

That worked perfectly.  While it doesn't display a text label to alert the user, it prevents them from submitting an incomplete record which is even better. Thank you.

@Kgray15 

One of my favorites - I even did a video on it that you might like (second half is all about custom input "forms").  Hope that gives you some more detail.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Dual Super User III
Dual Super User III

You can add a label to the screen and do the same logic in the visible property to show the label when they haven't completed the fields.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (63,478)