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

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

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 II
Super User II

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

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);

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

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 Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (30,561)