cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WebPortal
Post Prodigy
Post Prodigy

Dropdown in EMPTY ... again

Dropdown1:

 

Items: _mycollection

 

ID   |  Name

1    |  ABC

2    |  DEF

...

 

IsSearchable: true

 

DisplayFields: "Name"

SearchFields: "ID"

 

However:

Combobox1 is EMPTY. No search, no select, nothing!

 

I'm just trying to understand the logic of this, and why it is so erratic.

Can anyone help?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@WebPortal 

Actually, sorry the formula should have been this:

With({dt:Sort(Table, Name)},
    ForAll(
        Sequence(CountRows(dt)+1, 0),
        If(Value=0, Patch(Defaults(Table),{Name:"_vazio"}), Last(FirstN(dt, Value)))
    )
)

This will give you all of the columns from your record.

 

If you want to narrow to just Name and ID, then you can change to the following :

With({dt:Sort(Table, Name)},
    ForAll(
        Sequence(CountRows(dt)+1, 0),
        If(Value=0, {Name:"_vazio", ID:0}, Last(FirstN(dt, Value)))
    )
)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

18 REPLIES 18
eka24
Super User III
Super User III

Please how is the collection created, Onvisible?

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

WebPortal
Post Prodigy
Post Prodigy

@eka24
Yes, onvisible. Does it matter?

WebPortal
Post Prodigy
Post Prodigy

Now I have closed and reopened the app and I get an error!

 

It wasn't there before I closed the app....

 

Anyway, here it is:

 

WebPortal_0-1611076696692.png

And what is Combobox1.SearchItems I don't know...

RandyHayes
Super User III
Super User III

@WebPortal 

What is your collection on _mycollection defined as?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
WebPortal
Post Prodigy
Post Prodigy

ClearCollect(__mycollection, {Name: "_vazio"});
Collect(_mycollection, Sort(Table, Name, Ascending))

RandyHayes
Super User III
Super User III

@WebPortal 

So, let's take the collection out of the picture then as you don't need it for this combobox.

Set your Items formula to the following:

With({dt:Sort(Table, Name)},
    ForAll(
        Sequence(CountRows(dt)+1, 0),
        If(Value=0, {Name:"_vazio"}, Last(FirstN(dt, Value)))
    )
)

This will give you a dynamic list of sorted items with the first one being "_vazio"

 

Now, go through the Edit Fields on the combobox in the right properties pane of the designer and make sure that the Primary text and search text are as you want them.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
WebPortal
Post Prodigy
Post Prodigy

Thanks,

That returns the error: "Name isn't valid. This identifier isn't recognized."

 

This works:

Sort(Table, Name, Ascending)

 

ALL I want is to add an empty "_vazio" at the beginning, so the user may select the empty values...

RandyHayes
Super User III
Super User III

@WebPortal 

So the formula I provided you should have worked verbatim as-is.  

Can you put it in place again and give me a screenshot of the formula with the error shown?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
WebPortal
Post Prodigy
Post Prodigy

Sure, the formula works well on an empty screen.

It just doesn't work on the screen I want it.

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

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (20,614)