cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Improve if statement for error message on selected.value(Option set) cards and visibility behavior

I have an error message that will populate the top screen whenever the values that are provided in the drop down box are not selected or values are typed. I have 2 questions:

1. How can I improve this if statement to check if the values selected are from the values listed in the drop down (Ensure that values weren't typed).

2. The error message is visible on screen refresh due to all my fields being reset every time the screen refreshes (entering and exiting the screen prompts a refresh), how can I make the message visible only when the user has clicked on the field below whilst leaving the preceding field blank/incorrect selection? That way users opening up the app and entering that screen aren't already faced with a error message.

 

If there is a completely different approach to this that is simpler I'm all ears!

 

See my images below:

 

Error message visible with first card values being shown (none selected)

Error message with options shownError message with options shown

 

If statement to check whether the value of the first card IS NOT a value that is listed for pre-selection

Ultimately this would need to be applied to all the cards in the form.

current formula for the first cardcurrent formula for the first card

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Hi @MattP13 ,

Assuming your field name is Department, firstly you need to ensure this does not display as soon as the screen opens, so on the OnChange of the dropdown, put this

If(
   Not(
      DataCardValue7.Selected.Result in Choices(YourListName.Department)
   )
   UpdateContext({vError:"Please enter a correct department in the Department field"})
)

The Text of the error label would be

vError

and in the Save and Exit screen code add this

UpdateContext({vError:Blank()})

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

Hi @MattP13 ,

Assuming your field name is Department, firstly you need to ensure this does not display as soon as the screen opens, so on the OnChange of the dropdown, put this

If(
   Not(
      DataCardValue7.Selected.Result in Choices(YourListName.Department)
   )
   UpdateContext({vError:"Please enter a correct department in the Department field"})
)

The Text of the error label would be

vError

and in the Save and Exit screen code add this

UpdateContext({vError:Blank()})

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

Highlighted

@WarrenBelzWorks like a charm, thanks Warren!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,111)