web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Make a field required ...
Power Apps
Unanswered

Make a field required when a certain condition is met and not submitting the form

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a very simple edit form where I ask users to input the result to different metric. After that, the app evaluates the metrics and assigns it a "fail" or "pass" status according to different thresholds. The idea is that if a metric is tagged as "fail" then the "comment" field of the form is required and not optional:

What I'm doing right now is to set the OnSelect property of the "Submit" button like this:

If(
Or(
And(Metrics_Gallery.Selected.'Goal type'="Less than", Value(MetricResult.Text)<=Value(Metrics_Gallery.Selected.Threshold)),
And(Metrics_Gallery.Selected.'Goal type'="More than", Value(MetricResult.Text)>=Value(Metrics_Gallery.Selected.Threshold)),
And(Metrics_Gallery.Selected.'Goal type'="Equal to", Value(MetricResult.Text)=Value(Metrics_Gallery.Selected.Threshold))),

Patch(SMCR,Metrics_Gallery.Selected,{Fail:"Pass"}),

Patch(SMCR,Metrics_Gallery.Selected,{Fail:"Fail"}))

;

SubmitForm(Form1)

 

So if the conditions are met, the metrics will be tagged as a "Pass" and then the form will be submitted. If the conditions are not met, then the metric will be tagged as a "fail", and then the form should be submitted but fail, because I set up the following condition for the required property of the comment section:

 

If(Metrics_Gallery.Selected.Fail="Fail",true,false)

 

I was hoping that after clicking on the submit button, if a metric failed then it would be tagged as "fail", and then the SubmitForm instruction wouldn't work because the comment would be neccesary to submit.

What is happening right now is that the failing metric is tagged as "fail", BUT the form is being submitted even though the comment is being left blank.

 

Any idea on how to solve this?

 

Categories:
  • Geeks_D Profile Picture
    1,169 on at

    Include the Submit Statement in your if rather than outside the IF 

     

    In your IF, Check for the statement that equates to true and Submit the form if its true, else Add a notification for Metric failed  

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I tried this, but then if a person actually submits a comment the I also need the form to be submitted.

    So if metrics "pass" -> Submit immediately
    If metrics "fails" and comment section is blank -> Do not submit
    If metrics "fails" and comment section is not blank -> Do submit

    I know I can write a gigant IF function with all of these requirements, but I thought that trying to submit a form AFTER having written the Fail/Pass status and making a field required if the status was a Fail would be sufficient. I'm trying to avoid having to write a giant formula because then the powerapps gets super slow...

  • Geeks_D Profile Picture
    1,169 on at

    Okay i will advise this option 

    Since Your comment textbox depends if the metrics are passed or failed, I suggest you add the pass or fail if statement in the disabled property of the Comment TextBox 
    On the button to submit, Add an if statement to the disabled property as well  to check if the Comment box is not disabled and empty, This will only allow submission when its passed and also check if its failed and comment is included 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard