Related Service

SharePoint Development

Know more about SharePoint Development

Learn More

Power Apps – Model Driven Apps (Part 2)

Published: Sep 7, 2020

In our last blog of this PowerApps series, we have gone through the below points:

  1. Power Platform
  2. PowerApps
  3. 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.

Model-driven apps

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.
    Select option Model driven app from blank
  • Click on Create.
  • Enter the App Name, its Unique Name, and Description, which is optional. Click on Done.
    Enter the App Name
  • After the app is created, it will redirect to the App Designer screen.
    App Designer screen

  • Now, the app is created, and we can develop an app using the below three stages.

    1. Designing Business Data
    2. Defining business logic
    3. 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.
    Select option Entities

  • Default Entities list will be displayed.
  • To create a new Entity, click on the “New Entity” option on top of the page.
    click on New Entity

  • Enter the Entity name, add the primary field of the Entity and click on the Create button.
    Enter the Entity name
  • The Entity will be created. Click on the Entity name to view its details. Consider here, Entity named “CustomerDetails” is created.
    CustomerDetails

  • The page will display the default fields of the Entity. Click on the “Add field” option to create custom fields required by the app.
    Add field

  • Enter the field name, select its data type, and click on the “Done” option at the bottom.
    select its datatype

  • Currently, we have created a few custom fields with different data types as below:
    1. Customer Name → Text
    2. Customer Number → Phone
    3. Order Items → Whole Number
    4. 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.
    clicking the Entities
  • Select the custom created Entity from the list of Entities, and it will be added under the Entities section.
    Select the custom created Entity

  • 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.
    Business Process option
  • Provide the name to the process, select the Entity on which the process is to be attached and then click OK.
    Provide the name to the process

  • A designer will open where a default stage is added.
    A designer will open
  • Rename the stage by clicking on it and hit the “Apply” button.
    Rename the stage by clicking

  • A Data Step is included in the stage. Edit it by clicking on “Details” and then click on the Data Step.
    Edit it by clicking on Details

  • 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.
    Change the name of the Data Step

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 Stage box
  • Click on the “+” symbol to add a new Data Step.
  • Currently, the stage is defined to add Customer Name and Customer Number.
    the stage is defined to add Customer Name
  • New stage can be added by selecting the New Stage option under the “+ Add” symbol.
    New stage can be added
  • 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.
    new stage will be added
  • Now to add a condition, select the “Add Condition” option under the “+ Add” symbol. Set the condition details and click on Apply.
    Now to add a condition
    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.
    Order Items
  • From the designer’s top, click on Validate to check if there are any errors, and if there is no error, click on Save.
    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.
    select only one flow

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.
    Click on the Site Map option
  • Select the “Group” option under the “+ Add” symbol to add a Group.
    Select Group option
  • Group will be added to the pane. We can also drag and drop the Group, Area, and Subarea from the right panel.
    Group will be added in the pane
  • Add Subarea under Group and add the Entity to it.
    Add Subarea under Group
  • 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.

Click on Publish and then on Play option

  • 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 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.
    Add Details under Basic Details
  • After saving it, again clicking on the Basic Details tab will ask to move to Next Stage. Click on the Next Stage option.
    Click on 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.
    Place Order in next stage
  • The completed message will be displayed once the flow is completed.
    Completed message will be displayed
  • Clicking on the Subarea added on the left page, here it is “CustomerDetails” will display the newly added Customer Details.
    CustomerDetails will display

Conclusion

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!!!

More Blogs on Power Apps:
Power Apps + Microsoft Bots = Power Bots
Power Apps – Canvas Apps (Part 1)

Comments

  • Leave a message...

Related Articles

How do I Integrate CRM into Twilio Flex?

Dec 2, 2020

Things you must know before choosing Power BI

Nov 26, 2020

What are ORMs and How does it work?

Nov 24, 2020