cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Different Error messages should be displayed for a single label based on conditions of DatePicker Control

Hi,

I have a two Datepicker control(startdate and EndDate) and there is a Label ErrorMessage3 and LabelErrorMessage4 in two different DataCards.

 

2019_02_05_20_10_49_Expense_Report1_Saved_Unpublished_PowerApps.png

 

 

 

 

 

I need to validate Datepicker Control with two Conditions and with different error messages need to display by default visible is false for ErrorMessage3.

1)StartDate Datepicker control should not be greater that EndDate Datepicker control

 Ex: ErrorMessage3: StartDate should not be greater than EndDate

2)For Startdate and EndDate should not select future dates

 Ex:ErrorMessage3: Future dates should not be selected

 

My question is how to display error message based on condtion and how to Make ErrorMessageVisible true.I have tried creating a context variable I have written code in below Text property of ErrorMessage3textpropPowerApps.png

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Different Error messages should be displayed for a single label based on conditions of DatePicker Control

You've got some general syntax errors in your formula.  Check your paren's and notice that you are missing some.

That's first.

Second - you can't use a statement like UpdateContext in the property like that.  That's a behavior statement.

 

Now...

What you want to look at is both the text property and the visible property of the ErrorMessage3 label.

What your label says is what is in the Text property -

    If(DataCardValue3.SelectedDate>Today(), "Future Dates cannot be selected", DataCardValue3.SelectedDate>DataCardValue4.SelectedDate, "Not greater than End Date")

When you see the label is based on the Visible property -

   (DataCardValue3.SelectedDate > Today() || DataCardValue3.SelectedDate > DataCardValue4.SelectedDate)

 

Hope that helps.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

2 REPLIES 2
Highlighted
Super User
Super User

Re: Different Error messages should be displayed for a single label based on conditions of DatePicker Control

You've got some general syntax errors in your formula.  Check your paren's and notice that you are missing some.

That's first.

Second - you can't use a statement like UpdateContext in the property like that.  That's a behavior statement.

 

Now...

What you want to look at is both the text property and the visible property of the ErrorMessage3 label.

What your label says is what is in the Text property -

    If(DataCardValue3.SelectedDate>Today(), "Future Dates cannot be selected", DataCardValue3.SelectedDate>DataCardValue4.SelectedDate, "Not greater than End Date")

When you see the label is based on the Visible property -

   (DataCardValue3.SelectedDate > Today() || DataCardValue3.SelectedDate > DataCardValue4.SelectedDate)

 

Hope that helps.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Frequent Visitor

Re: Different Error messages should be displayed for a single label based on conditions of DatePicker Control

Thanks for the reply!

It's working fine.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (3,653)