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?