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:
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!
Solved! Go to Solution.
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.
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!
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.
Learn how to create your own user groups today!
Check out the new Power Platform Community Connections gallery!
Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.