cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Unable to re-populate default selected items of combobox on app start using flow response parameters

Hey Guys,

 

I have created a flow that is able to extract a bunch of strings from a stored procedure in my on-premise SQL server management studio. The output of the stored procedure is as follows:

 

{
  "ResultSets": {
    "Table1": [
      {
        "description""Xcode"
      },
      {
        "description""XML Path Language (XPath)"
      }
    ]
  },
  "ReturnCode"0,
  "OutputParameters": {}
}
 
The response is ResultSets.Table1 which is:
[
      {
        "description""Xcode"
      },
      {
        "description""XML Path Language (XPath)"
      }
    ]
 
Screen OnVisible property:
Collect(User_skills, GetUserSkillsFlow.Run(LookUp('[dbo].[user]', email = varUser.Email, id))) which yields an empty collection of type 'Table'
 
DefaultSelectedItems property of Combobox : User_skills collection
 
The idea is to populate the default selected items when the user visits the page. Please let me know which part should be changed to achieve the desired result. Thanks!
1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Resident Rockstar
Resident Rockstar

I noticed that you have the email in the user table. So you better just use T-SQL join to add the email to the Skills table. You can take two approaches:

1)

Create view _Skills with email and add this as a connection to PowerApps. Then the filter will be easy to use directly on the Combobox, Power Automate is not needed anymore (I would prefer this approach).

 

2) in your stored procedure also add the email through join and take the email as input variable on sp and Flow (so delete the ID here). Collect the response, which is just a regular collection you can use directly on the Combobox. 

 

Both will skip the need to first get the user Id. 

 

Hope this helps.

 

Paul

View solution in original post

14 REPLIES 14
v-siky-msft
Community Support
Community Support

Hi @Anonymous ,

 

Could you please share the flow steps? What is the Items property of combobox?

I made a simple test on my side and the table can be passed to PowerApps properly. Please see my flow steps:

Snipaste_2020-05-15_15-22-06.png

 

Snipaste_2020-05-15_15-24-43.png

 

Please refer to my test to try again, and check the flow run history to see if the table1 was output successfully as follows.

Snipaste_2020-05-15_15-26-20.png

Hope this helps.
Sik

Anonymous
Not applicable

Hey @v-siky-msft 

 

My sincere apologies for not clearly stating the question. I need the default selected items to be populated on the app launch. The normal Combobox selection works just fine. I have attached detailed screenshots capturing every related screen and my attempted formulas which yield no error. Please take a look at it when you have time. Thank you so much for your help!

Hi @Anonymous ,

 

Both two ways( flow&User_skills and current uncommented codes) look good, the only expression problem is that you should save the lookup user  ID in a variable and reference the variable in Filter function, e.g. Filter(table, id = varUserID).

 

Could you please show me the collection data of User_skills and  Varselectedskills? It's more straightforward to start with the data.
Beyond that, the OnVisble property is not easy to trigger, could you please put the code to Button.OnSelect to make sure the code is trigger successfully?

Sik

Anonymous
Not applicable

Hey @v-siky-msft 

 

I made all the changes you mentioned but with no success. Please refer to the screenshots. I changed the commands from onvisible to onselect of a button. Still no success.

 

I do not think a collection can retain data on start so using it on clicking save button might not be effective in my limited knowledge of power apps. That is why I tried to use it on start of app or onvisible of screen. Direct approaches don't work as well.

 

Why can't I call a flow in the default selected items property? 

KroonOfficeSol
Resident Rockstar
Resident Rockstar

I noticed that you have the email in the user table. So you better just use T-SQL join to add the email to the Skills table. You can take two approaches:

1)

Create view _Skills with email and add this as a connection to PowerApps. Then the filter will be easy to use directly on the Combobox, Power Automate is not needed anymore (I would prefer this approach).

 

2) in your stored procedure also add the email through join and take the email as input variable on sp and Flow (so delete the ID here). Collect the response, which is just a regular collection you can use directly on the Combobox. 

 

Both will skip the need to first get the user Id. 

 

Hope this helps.

 

Paul

View solution in original post

Hi @Anonymous ,

 

Yes, OnStart and Onvisible properties are to trigger the code automatically, Button.OnSelect is only for test to see if the collection is generated. 

It turns out that the problem really is here that the User_Skills collection in both methods is not generated. 

So please debug from the following part:

1. when you trigger the codes on Button.OnSelect, post back the output of Response action in result of  flow you just ran.

2. add a Label in Screen, set Text to varuserid to see if the user id is correct.

3. check the SQL connection, refresh it or consider re-connect them.

Sik

Anonymous
Not applicable

Hey @KroonOfficeSol

 

The view worked fine with a small exception though. Ran into a different problem and it would be great if you can see where I went wrong with that(attached screenshots).

My next question out of curiosity is what was wrong with the earlier approach. The formulas never showed an error. I have done these sorts of lookups while saving data to my database and populating data to my apps. What went wrong here? Is it always better to use views for data extraction as opposed to using a combination of stored_procedure/flow?

 

Thank you for your help!

Anonymous
Not applicable

Hey @v-siky-msft 

 

Creating a view resolved my issue, albeit with a minor issue as I have mentioned in another reply. Thank you so much for providing me suggestions throughout this. I will post the complete solution once that issue is resolved so people who are new to power apps such as me can get an idea.

When you hover over the red triangle on the canvas you will find a better-explained error message sometimes. 

 

In this case, you should use the DefaultSelectedItems property of the combo box instead of the default property.

 

This property expects a record or collection (for multiselect). You should use the LookUp() formula and use ThisItem.PropertyYouLikeToLookupOn. Also get rid of all the search(0 and filter() formula's, then are not needed. So this becomes something like this: 

LookUp(
    datasource
    , field = ThisItem.Property
)

 

Then I is a little strange you use the User-Skills in the combobox, because the experience level probably is a lookup on this table in your SQL server, so an id. So your combobox should be the same for each field, which means you can just use a table({},{},{}) as items. Then take the same table({},{},{}) and surround them with the lookup() formula.

 

Hope this all makes sense.

 

Paul

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,976)