In canvas apps, the first thing that you should do after creating a new app is to connect it to the data sources. Canvas apps support a variety of data connectors including but not limited to Office 365, SharePoint, Dynamics 365, and SQL Server. The data from these sources can be collected, updated, and displayed through these connectors.
To connect your canvas app to a data source, follow the below steps:
- Navigate to the ‘View’ tab and click on ‘Data sources’.
- Click on ‘+ Add data source’.
- In the ‘Data’ panel, select the type of data source you’d like to connect to, fill in the required information, and then click ‘Connect’.
A major advantage of using the Power Platform is that it empowers you to utilize data from multiple sources simultaneously. When you add more than one data source to a canvas app, these sources remain isolated and don’t interact with each other unless explicitly programmed to do so.
Understanding Delegation
Delegation is an essential principle to understand while working with data sources in Canvas Apps. When working with large sets of data, fetching all the data together isn’t always feasible or efficient. Here’s where delegation comes in. This is a process by which the app communicates the operations to the data source where they are processed, and only the required data is then returned.
However, not all data sources support all the delegation functions. Below is the table illustrating the delegation support of sources:
Data Source | Supported Delegation Functions |
---|---|
SharePoint | Lookup functions, Aggregate functions |
Dynamics 365 | All Delegation functions |
SQL Server | All Delegation functions |
Working with Collections in Canvas Apps
A collection in a canvas app is a handy way of grouping related data together, which you can then perform operations on as one unit. A collection is created, updated, and managed using the ‘Collect’, ‘Clear’, and ‘ClearCollect’ functions.
For example, if you have a form in your app to populate a collection with data on button press, you could use the following code:
Collect(ProductReview, {Review: TextInput1.Text, Rating: Value(Slider1.Value)});
In this line of code, ‘ProductReview’ is the collection name, and the fields ‘Review’ and ‘Rating’ are populating with the data from ‘TextInput1’ and ‘Slider1’.
The concept of connecting to various data sources in canvas apps is fundamental to designing powerful and dynamic apps. The ability to leverage multiple data sources, understand delegation and collections allows app builders to construct complex apps that handle and process significant amounts of data. Understanding these concepts will be highly beneficial in the PL-100 Microsoft Power Platform App Maker exam.
Practice Test
True/false: One can connect to multiple data sources in the canvas apps of Microsoft Power Platform.
- True
- False
Answer: True
Explanation: Microsoft Power Platform enables users to connect their canvas apps to multiple data sources to pull in and manipulate data.
Multiple choice: Which of the following can be used as data sources when using canvas apps?
- A) SharePoint
- B) Excel
- C) SQL server
- D) Google Sheets
Answer: A, B, C
Explanation: SharePoint, Excel, and SQL Server are valid data sources in canvas apps. Google Sheets, however, is not supported.
Multiple choice: Which element in the Canvas app is primarily used to connect to the data source?
- A) Design window
- B) Command Line Interface
- C) Connector
- D) App Checker
Answer: C. Connector
Explanation: Connector is mainly used in the Canvas app to connect to various data sources.
True/False: You can only create a connection to a data source from the canvas app studio.
- True
- False
Answer: False
Explanation: You can create a connection to a data source from both the canvas app studio and the Power Apps home.
Multiple choice: What is the main purpose of a connection in a Canvas App?
- A) It enables interaction with data and functionality from different services
- B) It provides a design template for apps
- C) It checks the app’s performance and efficiency
- D) It publishes the Canvas app
Answer: A. It enables interaction with data and functionality from different services
Explanation: The main purpose of creating a connection in a Canvas app is to interact with data and utilize functionality from different services.
True/False: In canvas apps, you can write to data sources as well as read from them.
- True
- False
Answer: True
Explanation: Canvas apps do allow both reading from and writing to connected data sources.
Multiple choice: What permissions are required to create connections to a data source in a canvas app?
- A) Owner
- B) Admin
- C) Contributor
- D) All of the above
Answer: D. All of the above
Explanation: The permissions required to create connections in Microsoft Power Apps vary based on the data source. Owner, Admin, and Contributor roles should generally have the necessary permissions.
True/False: You can share connections to data sources in a canvas app with other users.
- True
- False
Answer: True
Explanation: When you share a canvas app that uses a connection to a data source, you can also choose to share the connections that the app uses.
Multiple choice: What happens if a shared user doesn’t have permission to access a data source in a canvas app?
- A) The shared user won’t see the data
- B) The shared user can see the data but can’t edit it
- C) The data source will automatically grant permission
- D) The canvas app will crash
Answer: A. The shared user won’t see the data
Explanation: If a shared user does not have permission to a data source, they will not be able to view or manipulate the data from that source in the app.
True/False: It is not necessary to explicitly remove the data source connections when deleting a canvas app.
- True
- False
Answer: True
Explanation: When a canvas app is deleted, its data source connections are automatically removed and do not need to be removed manually.
Interview Questions
What is the first stage of connecting to data in canvas apps?
The first stage is to choose the data source you want to connect to from the Data pane.
What types of data sources can you connect to with canvas apps?
Canvas apps support many types of data sources including SharePoint, Excel, Dynamics 365, SQL server, Twitter, and many others.
How do you add a connection to a data source in a canvas app?
In a canvas app, a connection to a data source can be added by selecting “Data sources” from the View tab, followed by clicking on “+ Add data source.”
Can you connect to different types of data sources at the same time in Canvas Apps?
Yes, in a single canvas app, you can connect to different types of data sources simultaneously.
Is it possible to view and edit the data from your connected data source in your Canvas app?
Yes, depending on the permissions and configuration of the data source, you can view, edit, and create records from within your Canvas app.
How is data fetched from a connected data source in a Canvas App?
Data is fetched using delegable functions which provide scalable access to large sets of data by sending queries directly to the data source for execution.
What is the significance of the Refresh button in a canvas app data source connection?
The Refresh button manually syncs the most recent data from your data source into your canvas app.
How can you remove a data source from your Canvas app?
You can remove a data source by selecting it from the data sources list and then clicking on the Remove (‘-‘) button.
What is the limitation to the number of data sources you can connect to in a Canvas app?
There is no defined limit to the number of data sources you can connect to in a Canvas app.
Can you use the same data source in multiple canvas apps?
Yes, it is possible to use the same data source in multiple canvas apps.
Why might you experience errors while trying to connect to a data source in your Canvas app?
Errors with the connection can be due to reasons like incorrect credentials, network issues, or if the data source is not set up correctly for external connections.
Is it necessary to know how to write a SQL query to fetch data from a SQL server data source in Canvas Apps?
No, Canvas Apps has built-in functions to fetch, update, and manage data and it requires no knowledge of SQL queries.
Is the delegation warning relevant when connecting to large data sources in Canvas apps?
Yes, the delegation warning is important since it informs you when certain data-retrieval operations can’t be delegated to the data source, possibly resulting in incomplete data sets.
How can you manage and review data source connections in your Canvas App?
You can manage and review data source connections by selecting “Data sources” from the View tab, where all connected data sources are listed.
Is it possible to connect a canvas app to offline data sources?
No, canvas apps require an online connection to the data source to read from or write to it.