cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
geneZebra
Level 8

Looking for a better way to validate a form. sharing but looking for a better way

I've been lookng for a way to use the error message in a form to show text if a value is not unique. I was able to report the error during entry by reading the data card's text value but when I submit the form, the error message appears for a brief period of time.

 

This is what  I set the error text lable to in the data card

 

ErrLabel.Text = Parent.Error & If (LookUp(_coTrips,DataCardTripName.Text exactin Title).ID <> ThisItem.ID && !Button_SubmitChanges.DisplayMode <> Disabled, "Trip name is not unique")

 

Note I try to use the disabled check to avoid getting error while the submit is in porgress. That did not work since the disabled property does not change during the submit even though it does in the UI. This should be seen as a bug but that's just me.

 

I also tried 
Parent.Error & If (LookUp(_coTrips,DataCardTripName.Text exactin Title).ID <> ThisItem.ID && Button_SubmitChanges.Color = Button_SubmitChanges.DisabledColor , "Trip name is not unique")

 

And that too shows up during the submit.
I eventually got this to work by using the following but I now I have to put in a needless variable to set and clear within the Button's OnSelect function.

Parent.Error & If (LookUp(_coTrips,DataCardTripName.Text exactin Title).ID <> ThisItem.ID && !_bSubmitInProgess , "Trip name is not unique")

 

If anyone does have a better techninque please share. Otherwise, I help this post helps.

Also on a side note, if anyone knows of an easy way to see if any of the data cards in a form have their errr label set, please share. I am thinking something like setting the valid value in the data card but don't see a way to do this yet. 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
geneZebra
Level 8

Re: Looking for a better way to validate a form. sharing but looking for a better way

Acually, I tried it both ways and it seems I need to do the check on the error label it self not the data card. The data card's error value is not being set. I guess it does not evaluate until inside the submit.

 

Btn.DisplayMode: If(IsBlank(ErrorMsgTitle), Edit, Disabled) // this works
//If(IsBlank(EditFormUserTrip.Error), Edit, Disabled) //?? this does not work

 

Not title is from a SP list that needs this value to be unique otherwise the submit fails. I put that check in the error label and then check for empty in the DisplayMode property.

 

Thanks

View solution in original post

4 REPLIES 4
mdevaney
Level 8

Re: Looking for a better way to validate a form. sharing but looking for a better way


Also on a side note, if anyone knows of an easy way to see if any of the data cards in a form have their errr label set, please share. I am thinking something like setting the valid value in the data card but don't see a way to do this yet. 

 


 

You can check to see if a DataCard is in an error state by using the following code.  

 

Not(IsBlank(YourFieldName_DataCard.Error))

 

To check all the DataCards in a form simply reference the form instead.

 

And(
	Not(IsBlank(Form1.Error))
)

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

geneZebra
Level 8

Re: Looking for a better way to validate a form. sharing but looking for a better way

Thanks, I will use that to se the enabled property of the submit button. Too bad, there is no way to do get a list of all the data cards automatically but this can work.

 

Thanks.

mdevaney
Level 8

Re: Looking for a better way to validate a form. sharing but looking for a better way

@geneZebra 

I made change to my previous post.  Go take a looksee.

geneZebra
Level 8

Re: Looking for a better way to validate a form. sharing but looking for a better way

Acually, I tried it both ways and it seems I need to do the check on the error label it self not the data card. The data card's error value is not being set. I guess it does not evaluate until inside the submit.

 

Btn.DisplayMode: If(IsBlank(ErrorMsgTitle), Edit, Disabled) // this works
//If(IsBlank(EditFormUserTrip.Error), Edit, Disabled) //?? this does not work

 

Not title is from a SP list that needs this value to be unique otherwise the submit fails. I put that check in the error label and then check for empty in the DisplayMode property.

 

Thanks

View solution in original post

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Kudoed Authors
Users Online
Currently online: 275 members 5,284 guests
Recent signins:
Please welcome our newest community members: