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

Combobox datasource REST API custom connector - how to set default

Hi,

I have a combobox with the items based on a get call from a custom connector.

The combobox lists employees.

Based on current user logged in, I want default value to be current users initials (the letters before "@" in email address), fx MW.

Of course combobox does not want to accept a text value, because it wants a table value. How do i do this?

 

Items is like this: Custconnect.GetEmployees(envvarTenantid, envvarEnvironmentname, envvarCompanyid).value <- returns a collection.

 

A workaround would be to make a collection of the api call like:

ClearCollect(collEmployees, Custconnect.GetEmployees(envvarTenantid, envvarEnvironmentname, envvarCompanyid).value)

And then have items be collEmployees, and defaultselecteditems be something like

Filter(collEmployees, no = curuser.email)

That solution would need to run clearcollect when opening that screen, which is a call to much if the user doesn't want to use the combobox.

 

What is best/good solution?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @MadW ,

Do you want display current user's email address initials as the combo box default selected item?
Actually, I think the solution that you provided is already the best solution.

Please notice one key point:
combo box's default selected item should be one item of the combo box's Items.

If you set combo box's DefaultSelectedItem to a value that does not exist in combo box's Items, it will not display correctly.

 

So the solution should be that:
save the combo box's Items as a collection, add user's email address initials in this collection

set the combo box's Items and DefaultSelectedItem based on this collection.

 

For example:

set the app's OnStart:

ClearCollect(collection1,Custconnect.GetEmployees(envvarTenantid, envvarEnvironmentname, envvarCompanyid).value);
Collect(collection1,{fieldname:First(Split(User().Email,"@")).Result})

set the combo box's Items:

collection1

set the combo box's DefaultSelectedItems:

Filter(collection1,fieldname in User().Email)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Community Support
Community Support

Hi @MadW ,

Do you want display current user's email address initials as the combo box default selected item?
Actually, I think the solution that you provided is already the best solution.

Please notice one key point:
combo box's default selected item should be one item of the combo box's Items.

If you set combo box's DefaultSelectedItem to a value that does not exist in combo box's Items, it will not display correctly.

 

So the solution should be that:
save the combo box's Items as a collection, add user's email address initials in this collection

set the combo box's Items and DefaultSelectedItem based on this collection.

 

For example:

set the app's OnStart:

ClearCollect(collection1,Custconnect.GetEmployees(envvarTenantid, envvarEnvironmentname, envvarCompanyid).value);
Collect(collection1,{fieldname:First(Split(User().Email,"@")).Result})

set the combo box's Items:

collection1

set the combo box's DefaultSelectedItems:

Filter(collection1,fieldname in User().Email)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (26,880)