cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Danny_L
Helper III
Helper III

If statment on a Button?

Hey everyone,

 

I'm wondering if this is possible.

 

I have 4 text boxes on an Edit Form:

Qty on Work Order

Total Qty

Qty Passed

Qty Failed

 

Qty on Work Order is tied to my ERP system

Total Qty is a calculated field summing Qty Passed and Qty Failed

Qty Passed is user input

Qty Failed is user input

 

I want to do an If statement on the "Submit" button that I have that submits the form. 

 

What I want to do is If Total Qty > Qty on Work Order, do not let the person submit the form and then display an error message.

 

Can this be done?? If so, what would the syntax look like?

 

Let me know if other information is needed.\

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Danny_L ,

Do you want to justify whether to submit the form based on data in that form?

Do you mean that :
1)Qty on Work Order, Qty Passed, Qty Failed are textinputs that you need to fill in data in the form?

2)Total Qty is one calculated field=Qty Passed+Qty Failed 

So you need to compare data in textinputs for Qty on Work Order, Qty Passed, Qty Failed?

If so, please set the button's OnSelect like this:

If(Value(QtyPassedtextinput.Text)+ Value(QtyFailedtextinput.Text)>
                                     Value(QtyonWorkOrdertextinput.Text),
Notify("please do not make Total Qty larger then Qty on Work Order!",NotificationType.Warning),
SubmitForm(formname)
)

//please replace with the textinput names.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
cwebb365
Impactful Individual
Impactful Individual

Sure, on the button depending on the value of your data. I would read straight from the datasource incase the qty changes instead of your form field, but something like

If( whatever_populates_the_Total Qty > Whatever_populates_ Qty, SubmitForm(), Set(varError,"Your asking for more Qty than we have of " & whatever_populates_Total Qty)

Then, you would put a label where you want the error and set it's Text property to varError. Then for visible on this label would be isBlank(varError) || isEmpty(varError)

This will submit the form if your condition is met or else show that error and display it.

You could put a Blank(varError); in front of the onselect if you wanted to reset it when clicking the button, or you can blank it out in another area when chaning Qty if you want to put a check in the onChange for that control.

Hope this helps.
v-yutliu-msft
Community Support
Community Support

Hi @Danny_L ,

Do you want to justify whether to submit the form based on data in that form?

Do you mean that :
1)Qty on Work Order, Qty Passed, Qty Failed are textinputs that you need to fill in data in the form?

2)Total Qty is one calculated field=Qty Passed+Qty Failed 

So you need to compare data in textinputs for Qty on Work Order, Qty Passed, Qty Failed?

If so, please set the button's OnSelect like this:

If(Value(QtyPassedtextinput.Text)+ Value(QtyFailedtextinput.Text)>
                                     Value(QtyonWorkOrdertextinput.Text),
Notify("please do not make Total Qty larger then Qty on Work Order!",NotificationType.Warning),
SubmitForm(formname)
)

//please replace with the textinput names.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

That did it!!

 

Thank you 😀

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (52,383)