Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Conditionally make fields required

(0) ShareShare
ReportReport
Posted on by

I have two fields in a PowerApp form that conditionally make each other required based on their values. One field is "Number of interactions" and the other is "Cost of Interactions". What I would like to happen is if the Number of Interactions is >0 (I have a Coalesce statement on the datacard's Update property to make sure they don't space out the text), then the Cost of Interactions field is required, and must have a value >0. It that condition doesn't exist, then I want an error message to appear and not allow a successful form submission. In addition, I want a required column to stop form submission.

Likewise, if the Cost of Interactions > 0 (I also have a Coalesce statement on this datacard's Update property to make sure they don't space out the text), then the Number of Interactions field is required and must have a value >0. If that condition doesn't exist, then I want an error message to appear and not allow a successful form submission. In addition, I want a required column to stop form submission.

I have placed with each datacard's Required property, but obviously am missing something because it is allowing me (successful form submission) to put an amount in with 0 interactions and add 10 interactions with a zero amount.

Any suggestions?

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 144,858 on at
    Re: Conditionally make fields required

    Hi @AnnetteM ,

    In the Required property of each Data Card (use your control names) 'Cost of Interactions'

    Value(InteractionsNumberBox.Text) > 0

    and in 'Number of Interactions'

    Value(InteractionsCostBox.Text) > 0

    As an additional check

    If(
     FormName.Valid,
     SubmitForm(FormName),
     Notify( . . . . )
    )

     

    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

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

Kickstarter Events…

Register for Microsoft Kickstarter Events…

Tuesday Tip #12 Start your Super User…

Welcome to a brand new series, Tuesday Tips…

Tuesday Tip #13 Writing Effective Answers…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,858

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,505

Leaderboard