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

Highlighted
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
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,062)