cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
simms7400
Post Prodigy
Post Prodigy

Validation on Form Submission

Hi Folks -

I was wondering the best way to go about establishing a validation in PowerApps? Allow me to give the requirements.

 

I have a table called "rdInvestments" and for purposes of this dicussion, here are the 3 columns from my table and sample data:

 

example.jpg

 

AssetID is the PARENT to InvestmentID - think of tree form if this was a hierarchy in a system somewhere.

Now, the Column "PR_Lead_indcation" is where the action happens. Ultimately, there can be ONLY 1 value of "TRUE" for "PR_Lead_Indication" for sibling data elements. And obviously, to determine siblings, you can use the "AssetID" column.

 

So in the above example, all of the those PFI data elements are siblings with 1 like parent. I need to enable a validation where on both  new requests and edit requests, if someone tries to use a TRUE value when it already exists in it's sibliing group, to not allow it.

 

I'm not sure if this can be done on the actual field itself or on the Submit button.  Ultiately, I have a validation setup on my target financial application it gets imported into, however I'd prefer to catch the issue in the begining rather than getting a failure to import when I go to load this..Then, I need ot backtrack and then hunt down the end user to get clarity. Enabling the validation on the PowerApps side would save lots of time!

 

Please let me know your thoughts!

 

Thank you!

 

12 REPLIES 12

@simms7400 

Ah yes...the pictures are worth a thousand words!!

 

So, I believe here is the issue you are seeing.  When you are creating a new item, ThisItem is blank for the CompoundCode.

So, what you need to do is grab the value that is in the AssetID and not the ThisItem (I think this is the Asset Alias field on your form?).

So, let's say that's a text control...then you would alter the formula to this:

If(
	CountRows(
         Filter(rdInvestments, CompoundCode=DataCardValuexx.Text && !(PR_Lead_Indication.Value="FALSE"))
	) >=1 && PR_Lead_Indication.Value="FALSE", Disabled, Edit
)

If it's a drop-down or some other place that the current CompoundCode is coming from, then just substitute that in the above formula.

 

This should work equally well on new and edits.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

ThisItem was the trick, I needed to switch per your suggestion.  However, it still wasn't behaving like I needed it to.

 

Therefore, a couple tweaks and this is what I arrived at and it works as expected:

 

If(InvestmentEditForm.Mode = New && CountRows(
	Filter(rdInvestments, CompoundCode=DataCardValue41.Text && PR_Lead_Indication.Value="TRUE")) >=1, Disabled, 
	CountRows(
	Filter(rdInvestments, CompoundCode=ThisItem.CompoundCode && !(PR_Lead_Indication.Value="FALSE"))) >=1 && PR_Lead_Indication.Value="FALSE", Disabled, 
	Edit
)

Thanks again, Randy!! Have a grea holiday weekend!

@simms7400 

Ah I see, you needed to look at the other value as well in your statement.  Good deal!  Glad you got to a working point.

Have a great holiday weekend as well.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,065)