Power Apps – Model Driven Apps (Part 2)
In our last blog of this PowerApps series, we have gone through the below points:
Today, Our SharePoint Development Team will will walk you through the second type of Power Apps – Model driven apps. Model driven apps are newly added to Power Apps focusing on building apps with responsive UI which runs in any browser and devices with no code or low code approach required. The apps are useful as they provide the platform where we can design simple or complex apps. Model driven apps access CDS i.e. Common Data Service which uses entities to store data which is alike to Dynamics 365.
Table of Content
Model driven apps
Let’s go through this app creation and its execution through Customer Details Management demo.
Create model driven apps
To create and run model driven apps, Power Apps Plan 2 is required. First login to Power Apps by navigating to link https://make.powerapps.com.
- Select option ‘Model-driven app from blank’ amongst the three options available.
- Click on Create.
- Enter the App Name, its Unique Name and Description which is optional. Click on Done.
After the app is created, it will redirect to App Designer screen.
Now, the app is created, and we can develop an app using the below 3 stages.
- Designing Business Data
- Defining business logic
- Composing the app
Designing Business Data
The data of model driven is stored in Entities. Entities is like tables where columns are created having different datatypes as per the requirement of app. Follow the below steps to create Entities:
Select option Entities under Data in left navigation pane.
- Default Entities list will be displayed.
To create new Entity, click on “New Entity” option on top of the page.
- Enter the Entity name, add the primary field of the Entity and click on Create button.
The Entity will be created. Click on the Entity name to view its details. Consider here, Entity named “CustomerDetails” is created.
The page will display the default fields of the Entity. Click on “Add field” option to create custom fields required by app.
Enter the field name, select its datatype and click on “Done” option at the bottom.
- Currently, we have created few custom fields with different datatypes as below:
- Customer Name → Text
- Customer Number → Phone
- Order Items → Whole Number
- Place Order → Option Set
Inside Place Order field, we have set the options as Yes and No.
- Refresh the App Designer to reflect the changes made in the Entity. Add the newly created Entity to the App by clicking the “Entities” option in App Designer pane.
Select the custom created Entity from the list of Entities and it will be added under the Entities section.
- Similarly, other Entities as required by the app can be created and added to the App using App Designer pane.
Defining business logic
After the required Entities are created and added to the app, the next step is to create the business logic using those Entities. To create business logic, follow the below steps:
- In the App Designer pane, click on the Business Process option and select the Create New option.
Provide the name to the process, select the Entity on which the process is to be attached and then click OK.
- A designer will open where a default stage is added.
Rename the stage by clicking on it and hit the “Apply” button.
A Data Step is included in the stage. Edit it by clicking on “Details” and then click on the Data Step.
A pane will open on right hand side where properties of the Data Step can be changed. Change the name of the Data Step, select the entity field and click on Apply.
Note: You can check the Required attribute as per the requirement.
- Multiple Data Sets can be added to the Stage. Click on the Stage box and add another Data Step from the top.
- Click on the “+” symbol to add a new Data Step.
- Currently, the stage is defined to add Customer Name and Customer Number.
- New stage can be added by selecting New Stage option under “+ Add” symbol.
- Click on “+” symbol and new stage will be added. In this example, stage is asking the user to add the Number of Items to order.
- Now to add a condition, select “Add Condition” option under “+ Add” symbol. Set the condition details and click on Apply.
Here as per the current example, the condition is set to check if “Order Items” entered by the user is greater than 0. If it is greater than 0 then allow user to enter “PlaceOrder” field value. Provided below is the full screenshot of flow.
- From the top of the designer, click on Validate to check if there are any errors and if there is no error then click on Save.
- Now after the business process flow is created, the next step is to Activate the flow. Click on “Activate” option and flow will be attached to the App.
- Inside the App designer, select only one flow that is created.
Composing the App
After the entities are added and business logic for the flow is decided, the last step is to compose the app i.e. define the views, charts and form structure for the app.
- Click Forms to design the forms structure for the App. There is a provision where a new form will be created.
- Click View to select the views for the Entity when app is running. We can select multiple views and a new View can also be created.
- Similarly, for Charts and Dashboard, new Charts and Dashboard can be created.
- One important thing to configure is the Site Map. Site Map defines the navigation in our App. Click on the Site Map option and pane will open where we can define Groups, Area and Subarea.
- Select “Group” option under “+ Add” symbol, to add a Group.
- Group will be added in the pane. We can also drag and drop the Group, Area and Subarea from the right panel.
- Add Subarea under Group and add the Entity to it.
- These Groups, Area and Subarea will be displayed on the left pane when the App is running.
Run Model Driven apps
Once everything is defined and created for the app, the app is now ready to run.
Click on Publish and then on Play option available on top right corner of the App Designer.
- Now its time to add data to the Entity and check business flow.
- Click on “+ New” icon to add data to Entity.
- Add Details under Basic Details by clicking on Basic Details icon. Here, enter the Customer Number and Customer Number, and then hit on Save.
- After saving it, again clicking on Basic Details tab will ask to move to Next Stage. Click on Next Stage option.
- Enter Order Items and again click in Next Stage. Here as earlier defined in business process flow, if order items entered is greater than 0 then it will move to next stage else not.
- If Order Items entered is greater than 0 then it will ask for Place Order in next stage and then click Finish.
- Completed message will be displayed once the flow is completed.
- Clicking on the Subarea added on the left page, here it is “CustomerDetails” will display the newly added Customer Details.
Through this blog, one can start build a powerful Model driven apps. Based on the requirement, create ones’ simple/complex responsive accessible design running apps. This app type composes the different kind of components likes forms, views, dashboards, charts and various business process with great UI. Don’t wait to give a try to this powerful app and stay tuned for our next topic – PowerApps Portals!!!