Connecting A Datasource Dynamically In PowerApps Using Power Automate - Part Two


In my previous article, we completed the 1st module of this 2-part exercise where we loaded multiple data sources into a dropdown control. In this article, we will continue with the 2nd module and load content from the selected data source.
Collect Data based on a selected list
Similar to how we collected the list names, we will collect list data using PowerAutomate.
  1. Navigate here
  2. Click on “Create” and select “Instant flow”
  1. Give flow a name, like, “QuizBuzz_GetListData”. Select “PowerApps” as a trigger and click on “Create”.
  1. Add a New Step -> “Get Items”, and configure it with the Site URL where all quiz lists are created, for a list name, select “Ask in PowerApps” from dynamic content
  1. Next, initialize three String variable and name it “Questions”, “Answers” and “CorrectAnswers”
  1. Run the flow once, so that it generates the JSON for the “Get Items” step. We will use the JSON output in our “Parse JSON” step. For “Content”, use “value” from “Get Items” step and for “Schema”, click on “Generate from Sample” and copy the JSON output of “Get Items” step
  1. Next, loop through the parsed JSON and append questions, answers, and correct answers to appropriate variables. Ensure that the data is separated by a special character such as a semi-colon (;) or hash (#)
  1. Finally, add a step “Respond to a PowerApp or Flow”, this action will allow you to add an output. We will choose “Text”, provide an appropriate name to the response variables, and assign respective string variables to response outputs.
Currently, there is no option to send an Array or Collection to PowerApps. Hence, we pass the output as String and create a collection in PowerApps after receiving data from Flow.
Loading Content in PowerApps
We have sent the data from SharePoint Lists to PowerApps using PowerAutomate. Now, we need to convert these strings into respective collections that will be used in different controls in our Quiz App.
  1. Navigate here
  2. Click on “Apps” and select the previously created app. Click on “Edit” to open the app in Edit mode.
  1. Add a button to the app and let’s call it “Start Quiz”. We will need to associate the flow in PowerApps. So, select the Button in the tree view, then click on "Action" -> "Power Automate". Now, select the flow that we had created earlier. This flow will also need a parameter from PowerApps, so let’s pass the selected value in lists dropdown as List Name parameter to Flow.
  1. In the”OnSelect” of the button, Run the Flow that was created earlier and collect the result in a variable. Since the result is in String format, we will convert it into a collection by splitting based on the special character provided
  1. In the same action, add one more collection, that will contain the answers for the current question
  1. Add a label that will hold the question for the quiz, set the “Text” property of the label as follows
  1. Add a Radio Buttons control, that will hold the answers for the quiz, set the “Items” property of this control as follows. “Shuffle” function allows the collection to be placed in random order.
  1. Now, add another button and call it “Next”. We will use this button to Remove items from collection one at a time and move through the remaining questions. In the “On Select” action of this button, set the property as follows
Final Outcome
Now, the app should be ready to test. Load some data in both of the lists in SharePoint. In the PowerApps, right-click on App -> Run OnStart, this should load the dropdown. “Play” the app and click through the quiz. You would see that the data is loaded based on the selection in the dropdown.