cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kumar9024021
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
PowerAddict
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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,049)