cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dave-ITMan
Helper IV
Helper IV

Include Default Dropdown Selection in IsBlank Code

Hi Experts,

 

On my OnSelect of my button, I have the below code to make sure that all fields aren't left blank before continuing to the next screen, all of the dropdown boxes have the default option set to "Please select an option", is there a way that I can include that to make sure the user actually selects something from that drop down list? Also in the notify message, is there a way of telling them which ones haven't been filled in? 

 

If(
    IsBlank('Dropdown-1'.Selected.Value) ||
    IsBlank('Date-Created'.SelectedDate) || 
    IsBlank('Dropdown-2'.Selected.Value) || 
    IsBlank('Date-Closed'.SelectedDate) || 
    IsBlank('Dropdown-3'.Selected.Value) || 
    IsBlank('Dropdown-4'.Selected.Value) || 
    IsBlank('Job-Number'.Text) || 
    IsBlank('Dropdown-5'.Selected.Value) || 
    IsBlank('Dropdown-6'.Selected.Value) || 
    IsBlank('Dropdown-7'.Selected.Value) || 
    IsBlank('Dropdown-8'.Selected.Value) || 
    IsBlank('Dropdown-9'.Selected.Value) || 
    IsBlank('Txt-1'.Text) || 
    IsBlank('Txt-2'.Text) || 
    IsBlank('Dropdown-10'.Selected.Value),
    
    Notify("Please fill out all items"),
    Navigate(Costs,Cover)
)

 

1 ACCEPTED SOLUTION

Accepted Solutions

APP ON START:

 

Set( varOnSubmit, false)

 

 

If(
    'Dropdown-1'.Selected.Value = "Please select an option" ||
    IsBlank('Date-Created'.SelectedDate) || 
    'Dropdown-2'.Selected.Value = "Please select an option" || 
    IsBlank('Date-Closed'.SelectedDate) || 
    'Dropdown-3'.Selected.Value = "Please select an option" || 
    'Dropdown-4'.Selected.Value = "Please select an option" || 
    IsBlank('Job-Number'.Text) || 
    'Dropdown-5'.Selected.Value = "Please select an option" || 
    'Dropdown-6'.Selected.Value = "Please select an option" || 
    'Dropdown-7'.Selected.Value = "Please select an option" || 
    'Dropdown-8'.Selected.Value = "Please select an option" || 
    'Dropdown-9'.Selected.Value = "Please select an option" || 
    IsBlank('Txt-1'.Text) || 
    IsBlank('Txt-2'.Text) || 
    'Dropdown-10'.Selected.Value = "Please select an option",
    
    Notify("Please fill out all items");
    Set(varOnSubmit, true),
    Navigate(Costs,Cover);
    Set(varOnSubmit, false)
)

 

 

 

View solution in original post

11 REPLIES 11
NandiniBhagya20
Solution Sage
Solution Sage

Hi,
In the formula that you have already written you can add condition if users have not selected any option from the dropdown using below formula - Dropdown1.Selected.Value = "Please select an option"
You can also change the text box border color to red if the field is blank and submit button is clicked so that users will be able to recognise easily the fields that are blank


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Nogueira1306
Super User
Super User

Tou can only identify the field if you do the validation field by field.

If it is a dropdown, the fields will never be blank so I think that you sohuld do this:

 

If(
    'Dropdown-1'.Selected.Value = "Please select an option" ||
    IsBlank('Date-Created'.SelectedDate) || 
    'Dropdown-2'.Selected.Value = "Please select an option" || 
    IsBlank('Date-Closed'.SelectedDate) || 
    'Dropdown-3'.Selected.Value = "Please select an option" || 
    'Dropdown-4'.Selected.Value = "Please select an option" || 
    IsBlank('Job-Number'.Text) || 
    'Dropdown-5'.Selected.Value = "Please select an option" || 
    'Dropdown-6'.Selected.Value = "Please select an option" || 
    'Dropdown-7'.Selected.Value = "Please select an option" || 
    'Dropdown-8'.Selected.Value = "Please select an option" || 
    'Dropdown-9'.Selected.Value = "Please select an option" || 
    IsBlank('Txt-1'.Text) || 
    IsBlank('Txt-2'.Text) || 
    'Dropdown-10'.Selected.Value = "Please select an option",
    
    Notify("Please fill out all items"),
    Navigate(Costs,Cover)
)
Dave-ITMan
Helper IV
Helper IV

Thanks @NandiniBhagya20 and @Nogueira1306 i've used Nogueira1306's solution in the code of the submit button which works great thank you. Can you advise how I can set the border colour to red if it's blank or "please select an option"? 

Write this on the border property:

If(IsBlank('Dropdown-1'.Selected.Value) || 'Dropdown-1'.Selected.Value = "Please select an option", Red, ANOTHERCOLOR)

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,

Gonçalo Nogueira

Check my LinkedIn!

Buy me a coffee!

Check my User Group (pt-PT)!

Last Post on Community

My website!

 

Hi,
If you want to have red border color on button click then you will have to use a variable and on button click set it to true - UpdateContext({varButtonClick: true })

In borderColor property of your field you can add below formula - 
If(varButtonClick && ('Dropdown-1'.Selected.Value = "Please select an option" || IsBlank('Dropdown-1'.Selected.Value), Red, Parent.BorderColor)


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

@Nogueira1306 thank you for this, that works. Is there a way to only show the red border after clicking the Next Page OnSubmit button though as the appearance doesn't look too appealing when the user first goes onto the app? 

You can try to have a var.. like.. on app on start:
Set( varOnSubmit, false)

 

When you submit the form, write:

Set( varOnSubmit, true)

 

On border property:

 

If(varOnSubmit && (IsBlank('Dropdown-1'.Selected.Value) || 'Dropdown-1'.Selected.Value = "Please select an option"), Red, ANOTHERCOLOR)

 

After submit:

Set( varOnSubmit, false)

Hi @Nogueira1306 and @NandiniBhagya20 thanks for your replies.

 

  1. Where do I need to put Set( varOnSubmit, false)?
  2. Where do I need to put Set( varOnSubmit, false)? I don't have an After submit on my icon which goes to the next page
  3. How do I include Set( varOnSubmit, true) into my OnSelect code below?
    If(
        'Dropdown-1'.Selected.Value = "Please select an option" ||
        IsBlank('Date-Created'.SelectedDate) || 
        'Dropdown-2'.Selected.Value = "Please select an option" || 
        IsBlank('Date-Closed'.SelectedDate) || 
        'Dropdown-3'.Selected.Value = "Please select an option" || 
        'Dropdown-4'.Selected.Value = "Please select an option" || 
        IsBlank('Job-Number'.Text) || 
        'Dropdown-5'.Selected.Value = "Please select an option" || 
        'Dropdown-6'.Selected.Value = "Please select an option" || 
        'Dropdown-7'.Selected.Value = "Please select an option" || 
        'Dropdown-8'.Selected.Value = "Please select an option" || 
        'Dropdown-9'.Selected.Value = "Please select an option" || 
        IsBlank('Txt-1'.Text) || 
        IsBlank('Txt-2'.Text) || 
        'Dropdown-10'.Selected.Value = "Please select an option",
        
        Notify("Please fill out all items"),
        Navigate(Costs,Cover)
    )

 

APP ON START:

 

Set( varOnSubmit, false)

 

 

If(
    'Dropdown-1'.Selected.Value = "Please select an option" ||
    IsBlank('Date-Created'.SelectedDate) || 
    'Dropdown-2'.Selected.Value = "Please select an option" || 
    IsBlank('Date-Closed'.SelectedDate) || 
    'Dropdown-3'.Selected.Value = "Please select an option" || 
    'Dropdown-4'.Selected.Value = "Please select an option" || 
    IsBlank('Job-Number'.Text) || 
    'Dropdown-5'.Selected.Value = "Please select an option" || 
    'Dropdown-6'.Selected.Value = "Please select an option" || 
    'Dropdown-7'.Selected.Value = "Please select an option" || 
    'Dropdown-8'.Selected.Value = "Please select an option" || 
    'Dropdown-9'.Selected.Value = "Please select an option" || 
    IsBlank('Txt-1'.Text) || 
    IsBlank('Txt-2'.Text) || 
    'Dropdown-10'.Selected.Value = "Please select an option",
    
    Notify("Please fill out all items");
    Set(varOnSubmit, true),
    Navigate(Costs,Cover);
    Set(varOnSubmit, false)
)

 

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,454)