cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kumar9024021
Level: Powered On

Prevent me from submitting the form, if user enters certain value in textbox.

I have a textbox called CompanyName in my powerapp with SharePoint as the datasource. In the OnChange of the CompanyName textbox, I have written below piece of code.

 

If(LookUp('DS', DataCardValue5.Text =CompanyName && CompanyDecomissionedFlag="Y",true), Notify("You cannot enter this CompanyName, because it's decommissioned",NotificationType.Error), false);

 

Even-though the above code is NotificationType.Error, I am able to submit the form successfully.

 

It should actually prevent me from submitting the form, if I enter a companyname which is decommissioned. Any inputs would be helpful.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Prevent me from submitting the form, if user enters certain value in textbox.

I meant something like this:

If(LookUp('DS', DataCardValue5.Text =CompanyName && CompanyDecomissionedFlag="Y",true), false, SubmitForm(NewForm))

Let the Notify piece be in the OnChamge property as it was in your original post.

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
The Power Addict
https://thepoweraddict.com

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Prevent me from submitting the form, if user enters certain value in textbox.

I would include that same logic for the SubmitForm or Patch whatever you are using to submit the form (in the OnSelet property of a button or whatever you are using to submit the form).

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
The Power Addict
https://thepoweraddict.com
Kumar9024021
Level: Powered On

Re: Prevent me from submitting the form, if user enters certain value in textbox.

Hi @PowerAddict ,

 

I included the same piece of code in OnSelect of my submit button. When I enter the name in the textbox, which is decommissioned, click on submit button, it still allows me to save the record. It throws me the validation message as expected, but shouldn't allow me to save

 

If(LookUp('DS', DataCardValue5.Text =CompanyName && CompanyDecomissionedFlag="Y",true), Notify("You cannot enter this CompanyName, because it's decommissioned",NotificationType.Error), false); SubmitForm(NewForm);

Super User
Super User

Re: Prevent me from submitting the form, if user enters certain value in textbox.

I meant something like this:

If(LookUp('DS', DataCardValue5.Text =CompanyName && CompanyDecomissionedFlag="Y",true), false, SubmitForm(NewForm))

Let the Notify piece be in the OnChamge property as it was in your original post.

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
The Power Addict
https://thepoweraddict.com

View solution in original post

Super User
Super User

Re: Prevent me from submitting the form, if user enters certain value in textbox.

Glad I could help! Good luck with the rest of your app! Feel free to reach out in case of any questions!

Thanks,
Hardit Bhatia
The Power Addict
https://thepoweraddict.com

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,130)