Power Apps – Model Driven Apps (Part 2)
In our last blog of this PowerApps series, we have gone through the below points:
- Power Platform
- Canvas Apps
Today, Our SharePoint Development Team will walk you through the second type of Power Apps – Model-driven apps. Model-driven apps are recently 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 a 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 similar to Dynamics 365.
If you are a SharePoint developer and wish to learn model-driven apps, let’s go through this app creation and its execution through the 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 the 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 the App Designer screen.
Now, the app is created, and we can develop an app using the below three stages.
- Designing Business Data
- Defining business logic
- Composing the app
Designing Business Data
The data of model-driven is stored in Entities. Entities are like tables where columns are created with different data types as per the app’s requirement. SharePoint developers can follow the below steps to create Entities:
Select option Entities under Data in the left navigation pane.
- Default Entities list will be displayed.
To create a new Entity, click on the “New Entity” option on top of the page.
- Enter the Entity name, add the primary field of the Entity and click on the 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 the “Add field” option to create custom fields required by the app.
Enter the field name, select its data type, and click on the “Done” option at the bottom.
- Currently, we have created a few custom fields with different data types as below:
- Customer Name → Text
- Customer Number → Phone
- Order Items → Whole Number
- Place Order → Option Set
Inside the 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 the 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 the App Designer pane.
Defining business logic
After the required Entities are created and added to the app, the next step is to make 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 the right-hand side, where the properties of the Data Step can be changed. Change the name of the Data Step, select the entity field, and click on Apply.
Note: SharePoint developers 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 the New Stage option under the “+ Add” symbol.
- Click on the “+” symbol, and a new stage will be added. In this example, the stage is asking the user to add the Number of Items to order.
- Now to add a condition, select the “Add Condition” option under the “+ 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, allow the user to enter the “PlaceOrder” field value. Provided below is the full screenshot of the flow.
- From the designer’s top, click on Validate to check if there are any errors, and if there is no error, click on Save.
- Now after the business process flow is created, the next step is to Activate the flow. Click on the “Activate” option, and the 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.
- Click Forms to design the form 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 the 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 a pane will open to define Groups, Area and Subarea.
- Select the “Group” option under the “+ Add” symbol to add a Group.
- Group will be added to 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 the Play option available in the top right corner of the App Designer.
- Now it’s time to add data to the Entity and check business flow.
- Click on the “+ New” icon to add data to Entity.
- Add Details under Basic Details by clicking on the Basic Details icon. Here, enter the Customer Number and Customer Number, and then hit on Save.
- After saving it, again clicking on the Basic Details tab will ask to move to Next Stage. Click on the Next Stage option.
- Enter Order Items and again click on Next Stage. Here as earlier defined in the business process flow, if order items entered are more significant than 0, then it will move to the next stage else not.
- If Order Items entered is greater than 0, it will ask for Place Order in the next stage and then click Finish.
- The 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, SharePoint developers can start to build powerful Model-driven apps. Based on the requirement, create ones’ simple/complex responsive accessible design running apps. This app type composes the different kinds of components like forms, views, dashboards, charts, and various business processes with great UI. Don’t wait to try this powerful app, and stay tuned for our next topic – PowerApps Portals!!!