cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MadW
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
v-yutliu-msft
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
v-yutliu-msft
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
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

Power Apps Community Call

Monthly Power Apps Community Call

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

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (10,558)