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

@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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (17,441)