Hello everyone, we are back again with a new topic that is collections in Microsoft PowerApps. Collection is used to store data that can be used in your app. A collection is a group of items that are similar.
Let’s get started by creating and using collection in our Employee App.
Sign in to PowerApps and select New app button on the bottom of left action pane, In the next screen select Phone Layout from the Blank app. Now start creating app and add the following controls to your blank screen as shown below:
If you don’t know how to configure controls in PowerApps you can refer the following blog configure a control.
Select the Submit button and set it OnSelect property to the following formula:
Where Empdetail is the name of the collection that will be created after selecting Submit button. Name, Department, Position and Salary are the name of the field of Empdetail collection and TextInput1, TextInput2, TextInput3 and TextInput4 are the name of the TextInput control.
Now run your app by pressing F5 or Play icon on the top right of the screen and enter the employee data as shown below and finally select submit button:
A record will be added to the Empdetail collection, to verify it view your collection by navigating to File> Collections. You will find your collection with the specified name and a record that you added to it as shown below:
Add more records to your collection so that it can be utilize in any type of display control in a better way.
Now that we had created collection successfully and added couple of records to it, the next part is to make it useful in your application, for that add another screen to your app and rename it EmpHistory. Add a Line chart from the Charts menu present in the Insert tab and Set it Item property to Empdetail with Name on labels and Salary on Series 1, Line chart will be updated as shown in the screenshot below:
Add a List Box on the same screen from the Controls menu in the Insert tab and set its item property to the following to just display Department name in it:
The List Box will get populate with the department name as shown in the screenshot below:
Similarly you can also utilize your collection in Gallery control. With collection possibilities are numerous which depend on your app development theme that what you want to display in what way and on which control.
That’s all about PowerApps Collections from my side, we will be back soon with more useful and helpful topics on Microsoft technologies.