How to build Model-driven App in Power Apps - Part II
Introduction to Microsoft Dataverse
Microsoft Dataverse lets you securely store and manage data used by business applications.
Tables
Data within Dataverse is stored within a set of records called tables. A?table?is a set of records used to store data, similar to how a table stores data within a database.
Dataverse includes a base set of standard tables supporting common business scenarios connected to Dynamics 365 application data. You can also create custom tables specific to your organization and populate them with data that you import from lists in SharePoint, from Excel, or from PowerQuery. App makers can then use Power Apps to build rich applications using this data.
Dynamics 365 applications, such as Dynamics 365 Sales, Service, and Marketing, use Dataverse to store and secure data used by the applications. This means you can build apps using Power Apps and Dataverse directly against your core business data already used within Dynamics 365 without the need for manual integration.
Note - Dynamics 365 Finance, Dynamic 365 Supply Chain Management, and Dynamics 365 Retail currently require the configuration of Dual-Write to make your business data available within Dataverse.
For most organizations, it's a good idea to use the standard tables and columns as they were intended. But to meet your business needs, you can extend the functionality of standard tables by creating one or more custom tables to store information that's unique to your organization.
Logic and validation
Entities within Dataverse can leverage rich server-side logic and validation to ensure data quality. You can also reduce repetitive code in each app that creates and uses data within a table.
Security
Data in Dataverse is securely stored so that users can see it only if you grant them access. Role-based security, based on the Dynamics 365 system allows you to control access to tables for different users within your organization.
Table characteristics
Microsoft Dataverse is designed to let you quickly and easily create a data model for your application, based on the tables and the table metadata that you include in your app.
Tables describe the kinds of data that are stored in the Dataverse database. Each table corresponds to a database table and each column (also known as an attribute) within a table represents a column in that table.
In Dataverse, metadata (data about data), is a collection of tables. The table metadata is what controls the kinds of rows you can create and what kind of actions can be performed on them. When you use customization tools to create or edit tables, columns, and table relationships, you are editing this metadata.
The apps that your customers use to interact with the data in your environment depend on the table metadata, and they adapt as you customize the metadata.
When to use standard tables, and when to create new tables
Dataverse comes with many standard tables that support core business application capabilities. Each table also contains many metadata columns that represent common data that the system needs to store for that table. We recommend that you become familiar with the catalog of standard tables, and use them where possible because any applications written with standard tables will work as you expect in your environment without extra effort.
For minor changes, you might not have to create a custom table:
If standard tables don't work for your business needs, and if they can't be edited to meet those needs, consider creating a new table, column, or table relationship. If a standard table almost meets your business needs, you can use it as the basis for a new table.
Table relationships
Table relationships define the different ways table rows can be associated with rows from other tables or the same table. Table relationships are metadata. They let queries retrieve related data efficiently. Use table relationships to define the formal relationships between tables.
When you look at the solution explorer you might think that there are three types of table relationships but actually, there are only two, see below:
The N:1 (many-to-one) relationship type exists in the user interface because the designer shows you a view grouped by tables. 1:N relationships actually exist between tables and refer to each table as either a Primary/Current table or Related table. The related table, sometimes called the child table, has a lookup column that allows storing a reference to a row from the primary table, sometimes called the parent table. An N:1 relationship is just a 1:N relationship viewed from the related table.
Besides defining how rows can be related to other rows, 1:N table relationships also provide data to address the following questions:
Table types
Before creating or editing tables in Dataverse, you should understand the different types of tables that you can create. After a custom table is created, the table type can't be changed.
Types of table owners
When you create a custom table, the options for ownership are?User or team-owned, or?Organization-owned. After a table is created, you can’t change the ownership.
Activity tables
An?activity?is an action that a calendar entry can be made for. Activities have these characteristics:
Activity tables can be owned only by a user or team. They can't be owned by an organization.
The following default activity tables are available:
Custom activity tables
You can create new custom activity tables. The metadata values of activity tables differ from the metadata values of other tables. For example, the?primary?column is set to?Subject.
Business Rules
Business rules provide a simple interface to implement and maintain fast-changing and commonly used rules. The business rules defined for a table apply to both canvas apps and model-driven apps if the table is used in the app.
By combining conditions and actions, you can do any of the following with business rules:
Differences between canvas and model-driven apps
Model-driven apps can use all actions available on business rules, however not all business rule actions are available for canvas apps at this time. The following actions are not available on Canvas apps:
Dual-write vs. virtual tables
Microsoft Dataverse allows for many different connections to external data sources. Dual-write and virtual tables (or virtual entities) allow Dataverse to access this data and write back to the original data source.
Dual-write
Dual-write is an out-of-box infrastructure that provides near-real-time interaction between Dataverse and Finance and Operations apps. When data about customers, products, people, and operations flow beyond application boundaries, all departments in an organization are empowered.
Dual-write provides tightly coupled, bidirectional integration between Finance and Operations apps and Dataverse. Any data change in Finance and Operations apps causes writes to Dataverse, and any data change in Dataverse causes writes to Finance and Operations apps. This automated data flow provides an integrated user experience across the apps.
Find more information on?configuring Dual-write .
Virtual tables
Virtual tables (also known as virtual entities) enable the integration of data residing in external systems by seamlessly representing that data as tables in Microsoft Dataverse, without replication of data and often without custom coding.
Virtual tables replace previous client-side and server-side approaches to integrating external data, which required customized code and suffered from numerous limitations, including imperfect integration, data duplication, or extensive commitment of development resources. In addition, for administrators and system customizers, the use of virtual tables greatly simplifies administration and configuration.
Find more information on?configuring virtual tables .
When to use Dual-write vs. virtual tables?
Both Dual-write and virtual tables offer useful data integration functionality. It is important to understand when you need to use each tool.
Dual-write should be used when you are working with Dynamics 365 apps and need near real-time integration. Dual-write will duplicate the data in both directions (to and from Dataverse).
Virtual tables should be used when you are connecting to data sources outside of Dynamics 365. There may be built-in connectors for these data sources, or you may have to use a custom connector.
Create a Microsoft Dataverse table
In this unit, you'll create a table and then customize key components, like columns, relationships, views, and forms. You'll learn how to:
The tutorial follows the Contoso company, which is a pet grooming business that grooms dogs and cats. Contoso needs an app for client and pet tracking that can be used by employees on various devices.
Create a custom table
Sign in to?Power Apps ?and follow these steps to create a new custom table.
- Display name: Pet
- Display name:?Pet Name
You will notice in our example, the new table and primary column begin with?cree0_. More columns created for this table will also begin with?cree0, this is specific to our demo environment. When testing in your own environment this may look different.
Add and customize columns
- Display name:?Species
- Data type:?Choice
- Choice set:?+ New choice
- Searchable:?Yes
- Replace?New choice?with?Dog.
- Select?Add new item.
- Replace?New choice?with?Cat.
- Select?Save.
- Display name:?Breed
- Data type:?Text
- Searchable:?Yes
- Display name:?Appointment date
- Data type:?Date and Time
- Searchable:?Yes
Add a relationship
Notice that when you add a many-to-one relationship, an?Account?column of the?Lookup?data type is automatically added to your list of columns on the?Columns?tab.
领英推荐
Customize a view
- Account
- Appointment date
- Breed
- Species
Customize the main form
Create a table and import data into your Microsoft Dataverse database
You can import data into your Microsoft Dataverse database in bulk from Microsoft Excel or CSV files.
Every table has required columns that must exist in your input file. We recommend that you create a template. A template will save you time and effort. First, export data from the table. You'll use the same file (updated with your data) to import data into the table.
Create a file template
You can do a one-time data export from a standard table or a custom table, and you can export data from more than one table at a time. If you export data from more than one table, each table is exported into its own Microsoft CSV file. In this example, you'll see how to export the?Pet?table but remember you could select several tables to export if you would like.
Copy data into your template
When you add data to a template file, you must make sure the data is unique. You can use either?primary keys?or?alternate keys.
- Appointment date
- Breed
- Pet Name
- Species
Import the file
- Import Sequence Number
- Owning Business Unit
- Pet
- Status Reason Value
- Status Value
- Time Zone Rule Version Number
- UTC Conversion Time Zone Code
- Version Number
Notice that the Account column is empty, this is because when you updated the Excel export file and update columns you were not instructed to update this column. The reason you were not instructed to update the Account column is that you cannot set a lookup value when importing data from Excel, this must be done from Power Apps.
Create a custom table and import data
Scenario
The current sales process for your company is manual and updates are only provided each Friday. To simplify this process, minimize the opportunity for mistakes, and improve visibility, you have decided you want to create a new app to track sales leads and automatically calculate the forecasted revenue. You want to use Common Data Service to store the list of potential customers.
Creating a Custom table
- Display name:?Prospects
- Display name:?Prospect Name
- Display name:?Stage
- Data Type:?Choice
- Display name:?Prospect Stage
- Name:?prospectstage
- Add the following items/options:?Lead,?Opportunity,?Won,?Lost
- Default value:?Lead
- Change?Required?dropdown to?Required
- Display name:?Contract Amount
- Data Type:?Currency
- Display name:?Probability
- Data Type:?Whole Number
- Display name:?Forecasted Revenue
- Data Type:?Currency
- Select?+Add?for Calculated or Rollup
- Select?+Calculation
crXXX_contractamount * (crXXX_probability / 100)
Add a Business Rule
Importing Data from an Excel file
You will use the Excel spreadsheet named?Prospects ?for this exercise. Open the link, and select the Download button and save it locally.
- Contoso Flooring: Won.
- Fabrikam Inc: Won.
- Adventure Works: Lead.
- Adatum: Lead.
- VanArsdel: Lost.
- Relecloud: Opportunity.
Note - If you receive an error when selecting the?Get data from Excel?option, then your Power Apps license does not allow for importing Excel data.
- Contract Amount:?ContractAmount
- Prospect Name:?Name
- Stage Value:?Stage
- Probability:?Probability
Summary
Dataverse lets you securely store and manage data that are used by business applications. Standard and custom tables within Dataverse provide a secure and cloud-based storage option for your data.
Let's review what you've learned:
This article is part of Microsoft Certified: Power Platform App Maker Associate and will be one of many in the series of articles on my journey to become a Microsoft Power Platform Architect:
Until next time,
Nikola Basta
Business Solution Specialist at JYSK
2 年Hi Nikola. How did you embed google maps into your solution? Through a plugin or iframe? So far i have only managed to embed static google maps.