cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
morall
Microsoft
Microsoft

Set dropdown to blank by default

I've created a dropdown list

 

Items forumula:

 

Filter('OneEng Candidates', cr818_OneEngEvent.cr818_oneengeventid = DropdownEvent.Selected.cr818_oneengeventid)

 

 

I set the default value to the dropdown as: "" or "test" but it still keeps showing as the first item in the Items formula filter

 

Why is that? Does the formula override the Default? Do I need to save the app and reload?

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User III
Super User III

@morall 
I can help you with this 🙂

You'll have to create a collection in the and add a blank option.  Do this by creating a collection.

You'll probably need to create the collection in 2 places: OnVisible property of the app and the OnChange property of DropdownEvent.

ClearCollect(colDropdownOptions, {your_column_name: Blank()});
Collect(colDropdownOptions, Filter('OneEng Candidates', cr818_OneEngEvent.cr818_oneengeventid = DropdownEvent.Selected.cr818_oneengeventid).your_column_name;

 

Then refer to the collection in the Items property of your dropdown.

colDropdownOptions

 

A similar concept is shown in this example:

https://matthewdevaney.com/powerapps-collections-cookbook/unique-values-from-a-collection-with-a-bla...

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

View solution in original post

7 REPLIES 7
mdevaney
Super User III
Super User III

@morall 
I can help you with this 🙂

You'll have to create a collection in the and add a blank option.  Do this by creating a collection.

You'll probably need to create the collection in 2 places: OnVisible property of the app and the OnChange property of DropdownEvent.

ClearCollect(colDropdownOptions, {your_column_name: Blank()});
Collect(colDropdownOptions, Filter('OneEng Candidates', cr818_OneEngEvent.cr818_oneengeventid = DropdownEvent.Selected.cr818_oneengeventid).your_column_name;

 

Then refer to the collection in the Items property of your dropdown.

colDropdownOptions

 

A similar concept is shown in this example:

https://matthewdevaney.com/powerapps-collections-cookbook/unique-values-from-a-collection-with-a-bla...

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

View solution in original post

Just out of curiosity, the default is meant to select the default item from the list, not necessarily add create new items? 

@morall 

Yes, that's correct.  Your observation is the reason why we cannot default to blank if its not already within the dropdown items as an option.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

I threw this in App and ran Run On Start:

 

ClearCollect(colDropdownOptions, {Name: "Morgan"});
Collect(colDropdownOptions, Filter('OneEng Candidates', cr818_OneEngEvent.cr818_oneengeventid = DropdownEvent.Selected.cr818_oneengeventid).Name;

 

But only "Morgan" is showing up. I would have expected it to "combine" Morgan with the rest of the options. Can you see what I'm doing wrong  

Was missing a ")"

This is causing an error now on my Patch when trying to update an entity with the values in the dropdown menus:

The Patch code on a Button

 

ForAll(
    Gallery4.AllItems,
    Patch(
        'OneEng Candidates_Interviewers',
        Defaults('OneEng Candidates_Interviewers'),
        {
            Candidate: Slot1.Selected,
            Interviewer: Interviewer,
            IVSlot: Value(Label_Slot1.Text),
            Event: DropdownEvent.Selected,
            MorningOrAfternoon:drpdownMorA.Selected.Value
        }
    )
);

ForAll(
    Gallery4.AllItems,
    Patch(
        'OneEng Candidates_Interviewers',
        Defaults('OneEng Candidates_Interviewers'),
        {
            Candidate: Slot1.Selected,
            Interviewer: Interviewer,
            IVSlot: Value(Label_Slot2.Text),
            Event: DropdownEvent.Selected,
            MorningOrAfternoon:drpdownMorA.Selected.Value
        }
    )
);

 

 

"Invalid Argument type. Expecting a record value, but of a different schema."

 

Is this because previously it was looking at records in the dropdown, but now it's looking at a collection?

The table I'm patching this into is expecting a record value and it seems when I create a collection, it strips away the record value. Is there a way to handle this?

as a hack, not sure if there is a better way to do this:

 

 

 

Candidate: First(Filter('OneEng Candidates', Name = Slot1.Selected.Name)) 

 

 

 

The collection is returning a name, and I am trying to use that name as a filter on the 'OneEng Candidates' table, (the one I started with), and return the first record 

 

 

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

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

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

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