Thursday, May 22, 2025

Canvas Apps vs. Model-Driven Apps: Picking the Best Fit for Your Microsoft Power Platform Project

Hey there, app creators! If you’re diving into the world of Microsoft Power Platform, you’ve probably heard about Canvas Apps and Model-Driven Apps. These two approaches let you build awesome apps with minimal coding, but they’re pretty different in how they work and what they’re best for. Choosing the right one can make or break your project, so let’s break it down in a simple way. We’ll explore what makes each app type special, share some real-world examples, and look at the latest 2025 updates to help you decide which one fits your needs.

What Are Canvas Apps? Your Creative Playground

Canvas Apps are like a blank sketchbook where you get to design every detail. Using Power Apps Studio, you can drag and drop buttons, images, and forms to create an app that looks exactly how you want. It’s all about freedom and creativity!

Cool Features of Canvas Apps

  • Design Your Way: You control where everything goes—perfect for making apps that match your brand or fit specific devices like phones or tablets.
  • Power Fx Magic: This is Microsoft’s easy-to-use formula language that lets you add smart features, like filtering lists or triggering actions.
  • Tons of Connections: Link your app to over 1,000 data sources, like SharePoint, Excel, Dynamics 365, or even non-Microsoft tools like Google Workspace.
  • What’s New in 2025:
    • Better Undo/Redo (April 2025): You can undo up to 100 actions, and each one comes with a description to keep things clear.
    • Copilot Helper (April 2025): Update data or tweak layouts without leaving the canvas—super handy for quick edits.
    • Smart Paste (March 2025): Paste a screenshot or handwritten note, and AI fills in forms for you, cutting data entry time by 29%, per Microsoft’s tests.
    • Teamwork Mode (March 2025): Work on apps with your team in real time, so you don’t have to merge changes manually.

Real-Life Examples

Canvas Apps are great when you need a custom look or mobile-friendly features:

  • Field Service App: A delivery company might build an app for drivers to log orders, scan barcodes, or upload photos, all with a sleek mobile design connected to SharePoint.
  • Event Lead Tracker: Sales teams can create an app to collect leads at a conference, syncing them instantly to Dynamics 365.
  • Inventory Dashboard: A store could design a custom dashboard with charts and buttons to track stock levels, tailored for managers.

Why They Rock

  • Super Customizable: Make your app look unique and match your company’s vibe.
  • Flexible Connections: Works with tons of data sources, not just Microsoft ones.
  • Mobile-Friendly: Perfect for apps that need to shine on phones or tablets.

Things to Watch Out For

  • Takes Some Learning: You’ll need to get comfy with Power Fx and data connections to build complex apps.
  • Data Limits: By default, you can only pull 500 records for some queries. Fix: Use “delegable” queries to let the data source handle the heavy lifting.
  • Offline Glitches: The Connection.Connected formula might act up offline in Power Apps for Windows. Fix: Add a Timer control to delay certain actions.

What Are Model-Driven Apps? Your Structured Superhero

Model-Driven Apps are all about keeping things organized and quick. Instead of focusing on design, you set up your data and processes, and the platform builds a clean, consistent app for you. It’s perfect for big, data-heavy projects.

Cool Features of Model-Driven Apps

  • Data-First Design: Built on Microsoft Dataverse, these apps handle complex data like customer records or project tasks with ease.
  • Ready-Made Layouts: The app creates a user-friendly interface that works on any device, so you don’t have to design every screen.
  • App Designer: Add forms, charts, or dashboards with a simple visual tool, making development fast.
  • What’s New in 2025:
    • Copilot Chat with Multimedia (March 2025): Interact with your data using text, images, or videos for a richer experience.
    • Managed Availability (March 2025): Keeps your app running with automatic backups and disaster recovery, great for big teams.
    • Power CAT Tools (March 2025): A set of tools to make building apps easier with proven tips and tricks.

Real-Life Examples

Model-Driven Apps are awesome for structured, process-focused projects:

  • Employee Onboarding: HR can build an app to track new hires, training, and IT setup, with all data neatly linked in Dataverse.
  • Sales Tracking: Sales teams can manage leads, deals, and customer info, moving smoothly between related records.
  • Healthcare Management: Clinics can create apps to handle patient records, appointments, and treatments, keeping everything secure and organized.

Why They Rock

  • Fast to Build: Prebuilt layouts and tools mean you’re up and running quickly.
  • Great for Big Data: Handles complex data relationships like a pro.
  • Consistent Look: The same clean interface works everywhere, making it easy for users to learn.

Things to Watch Out For

  • Less Design Freedom: You can’t tweak the look as much as with Canvas Apps.
  • Custom Page Issues: Adding Canvas features to Model-Driven Apps (called custom pages) might not show updates until you republish. Fix: Republish the app after changes.
  • Mobile Limits: Custom pages don’t support offline mode or features like barcode scanning on mobile. Fix: Stick to online mode or avoid those features.
  • Hierarchy Tool Going Away (October 2025): A feature for showing data relationships is being removed. Fix: Turn it on in settings for now, but plan to switch soon.

Canvas vs. Model-Driven: A Quick Comparison

Feature Canvas Apps Model-Driven Apps
Design Style Build your own UI, total control Data-driven, auto-generated UI
Customization Tons of design and logic options Limited design, focused on data
Build Speed Slower for complex apps due to custom work Faster with prebuilt components
Data Connections 1,000+ sources, very flexible Mainly Dataverse, great for complex data
Best For Custom mobile apps, unique designs Enterprise apps, structured processes
Learning Curve Moderate (Power Fx, connectors) Easier (app designer, less design work)
2025 Updates Smart Paste, Coauthoring, Copilot Copilot Chat, Managed Availability

Real-World Examples: Which One to Pick?

Choosing between Canvas and Model-Driven Apps depends on what you’re trying to do. Here are two examples to help you decide:

Example: Mobile App for Field Workers

  • What You Need: A mobile app for technicians to log job details, take photos, and scan barcodes, with a custom look.
  • Best Choice: Canvas App
  • Why? You can design a mobile-friendly interface and add features like camera support. The 2025 Smart Paste feature makes data entry faster, and you can connect to SharePoint or Dynamics 365. For instance, a delivery company cut job logging time by 25% with a Canvas App tailored for drivers.

Example: Sales Management System

  • What You Need: An app to manage leads, deals, and customer data for a big sales team.
  • Best Choice: Model-Driven App
  • Why? It’s perfect for handling complex data like customer relationships in Dataverse. The 2025 Copilot Chat feature makes data exploration easy, and Managed Availability ensures the app stays online for global teams. A company might reduce sales cycle time by 20% with this setup.

Common Issues and Fixes

Both app types have some quirks, but here’s how to handle them:

  • Canvas Apps:
    • Problem: Some queries only pull 500 records. Fix: Use delegable queries or split up your data.
    • Problem: Offline mode can glitch with connection checks. Fix: Add a Timer to delay actions.
  • Model-Driven Apps:
    • Problem: Custom pages don’t update until republished. Fix: Republish the app after changes.
    • Problem: Custom pages don’t work offline on mobile. Fix: Use online mode for now.

Try the Monitor tool for both app types to track down issues like slow loading or data errors.

Tips to Choose the Right App Type

  1. Go for Canvas Apps if:
    • You want a custom, branded design.
    • Your app needs mobile features like camera or GPS.
    • You’re connecting to various data sources.
    • Example: A retail app with a unique loyalty dashboard.
  2. Go for Model-Driven Apps if:
    • You need to manage complex data or business processes.
    • You want a fast build with a standard look.
    • You’re using Dataverse or Dynamics 365.
    • Example: A CRM app for customer management.
  3. Try a Mix:
    • Use custom pages to add Canvas features to a Model-Driven App, like a quick-entry form in a sales app. Just remember to republish after updates (a 2025 quirk).
  4. Test New Features:
    • Set up a Developer Environment to play with 2025 features like Canvas Coauthoring or Copilot Chat. Check out make.powerapps.com and enable the “Try the new Power Apps experience” option.

Wrap-Up

Canvas Apps and Model-Driven Apps are both amazing tools in the Microsoft Power Platform, but they serve different purposes. Canvas Apps are your go-to for creative, custom designs, especially for mobile users. Model-Driven Apps are the way to go for quick, data-heavy apps with a consistent look. With cool 2025 updates like Copilot, Smart Paste, and better teamwork tools, both options are more powerful than ever.

Ready to start building? Head to make.powerapps.com to try things out, or check Microsoft’s guides for step-by-step help. If your project’s complex, consider chatting with a Power Apps pro to get it just right. Which app type are you leaning toward? Drop your thoughts or project ideas in the comments!

Power Apps and Dynamics 365 Licensing

🔹 Dynamics 365 and Power Platform Licensing – Detailed Breakdown

I will be honest — Microsoft licensing wasn’t always my favorite topic. Like many Power Apps developers, I focused on building solutions, not figuring out who’s allowed to use what.

A few months ago, I was leading a Power Apps project, during a project review meeting, questions started piling up:

  • “Can’t we just give everyone Power Apps licenses instead of Dynamics licenses to save cost?”
  • “Can a Team Member run this flow?”
  • “Is this Dataverse table covered by our license?”
  • “Do we need a Sales license just to store contact data?”

That’s why I’m writing this post. I’m writing this post because I’ve seen firsthand how confusing licensing can be. I’ve seen organizations spend weeks in building apps, and realize later that users aren’t even licensed to run them. Others overspend on licenses just to be safe, or under-license out of ignorance. In this blog i tried to break down the licensing into plain English — grounded in real project experience — so you can make decisions right from the start.

🔹 1. Power Apps Per User License: What Can You Do?

If a user has a Power Apps per user license, they can:

  • Build and run unlimited custom apps using Dataverse.
  • Use premium connectors (like SQL Server, Dataverse, HTTP, etc.).
  • Create workflows using Power Automate.

Important note: If you're building apps that use data from the same tables used by D365 Sales, that's fine — as long as you don’t use the full Sales app experience.

Dynamics 365 Sales is a packaged solution. So while Power Apps lets you read/write Sales data through your own custom apps, it does not give access to the full Sales interface or built-in processes.

✅ OK: Custom canvas or model-driven apps using Dataverse.
❌ Not OK: Using the full D365 Sales app UI or mimicking its full functionality.

🔹 2. Dynamics 365 Sales Enterprise License: What’s Included?

The D365 Sales Enterprise license gives users:

  • Full use of the packaged Sales app.
  • Rights to build and use custom Power Apps.
  • Access to Power Automate and premium connectors.

This means users can build apps, automate flows, and extend the Sales module — all without needing a separate Power Apps license.

🔹 3. D365 Customer Service Enterprise: Same Rules Apply

The Customer Service Enterprise license works the same way as Sales Enterprise.

Users can:

  • Use the full Customer Service app.
  • Build custom apps and flows for service-related tasks.
  • Access Dataverse and premium connectors.

No additional licensing needed for building extended solutions here either.

🔹 4. Dynamics 365 Team Member License: What Can’t You Do?

This is a lightweight license meant for basic tasks like:

  • Viewing data
  • Entering notes or time entries
  • Reading dashboards

However, users with this license cannot:

  • ❌ Build or run custom apps that access restricted tables (like Opportunity or Case).
  • ❌ Use Power Automate flows with premium connectors.
  • ❌ Run apps that replicate full D365 Sales/Service features.

Bottom line: This is for occasional users only — not for app builders or power users.

✅ Quick Summary Table

User License Can Use Custom Apps? Can Use D365 Apps? Use Premium Connectors? Custom Flows Allowed?
Power Apps Per User ✅ Yes, for custom data ❌ No, for full D365 apps ✅ Yes ✅ Yes
D365 Sales Enterprise ✅ Yes ✅ Yes ✅ Yes ✅ Yes
D365 Customer Service ✅ Yes ✅ Yes ✅ Yes ✅ Yes
D365 Team Member ⚠️ Limited ⚠️ Limited ❌ No ⚠️ Very Limited

Friday, May 9, 2025

Fixing the “No Name” Issue When Setting RegardingObjectId in Dataverse Plugins

Fixing the “No Name” Issue When Setting RegardingObjectId in Dataverse Plugins

When building plugins for Microsoft Dataverse, setting lookup fields like regardingobjectid can be tricky—especially with polymorphic lookups. A common issue developers face is seeing “No Name” in the UI even after setting the lookup value. This blog post explores why this happens and how to handle it properly in your plugin code.

The Problem

Suppose you’re assigning a broker to an Appointment record using a plugin. Your code might look like this:

EntityReference brokerRef = (EntityReference)appointmentEntity["crm_broker"];
appointmentEntity["regardingobjectid"] = new EntityReference(brokerRef.LogicalName, brokerRef.Id);

This sets the lookup correctly in terms of entity and ID, but the regardingobjectid shows up as “No Name” in the UI. Why?

The Cause

The EntityReference object also has a Name property, which is what the UI uses to display the label. In a Pre-Operation plugin, the record isn’t fully committed to the database yet, so Dataverse doesn’t resolve or populate this display name automatically for polymorphic lookups like regardingobjectid.

The Fix

To resolve this, explicitly retrieve the name, and all dependent attributes of the target record and assign it when setting the EntityReference:

EntityReference brokerRef = (EntityReference)appointmentEntity["crm_broker"];
Entity broker = service.Retrieve(brokerRef.LogicalName, brokerRef.Id, new ColumnSet("name"));
string brokerName = broker.GetAttributeValue<string>("name");

appointmentEntity["regardingobjectid"] = new EntityReference(brokerRef.LogicalName, brokerRef.Id)
{
    Name = brokerName
};

Why This Works

  • UI rendering depends on the Name property of the lookup reference. If it's missing, the form defaults to displaying "No Name".
  • In the Pre-Operation stage, the record and its references haven’t been persisted yet—so polymorphic lookups can't be resolved unless you provide the metadata yourself.
  • By manually setting the Name, you ensure the UI has what it needs to render the label correctly.

Additional Tips

  • ✅ Stage Awareness: Consider setting the regardingobjectid in a Post-Operation plugin if possible. This guarantees the record is committed and lookups are more reliably resolved.
  • ✅ Check Permissions: Ensure your plugin has adequate permissions to retrieve the broker entity’s name field.
  • ✅ Avoid UI Confusion: Even after correcting the plugin, browser caching or form loading issues might delay UI updates. Refresh the form or clear the cache to see changes.

Final Thoughts

Handling lookup fields—especially polymorphic ones like regardingobjectid—requires attention to detail. By explicitly setting the Name in your EntityReference, you ensure smoother user experiences and cleaner data presentation.

Still seeing “No Name”? Drop a comment or reach out—I’m happy to help you debug it further!

Saturday, May 3, 2025

Power Apps’ Ungroup(): Combining Tables for Dynamic Dropdowns

Power Apps’ Ungroup(): Combining Tables for Dynamic Dropdowns

Power Apps’ Ungroup(): Combining Tables for Dynamic Dropdowns

In Power Apps, building dynamic, user-friendly dropdowns often involves fetching distinct values from a data source and then prepending or appending custom options. A common challenge arises when you want to merge literal records (like an “All” choice) with a result set returned by functions such as Distinct(). In this post, we’ll deep-dive into the Ungroup() function and show you how it elegantly solves this problem—using the real-world example of a visitor check-in app where we need to list hosts in a dropdown.

📋 The Scenario: Visitor Management App

Imagine you’ve built a Canvas App called Visitor Check-In. Your SharePoint list, Visitor Records, tracks each visitor’s details, including a Person or Group column named Host.

On your front-desk interface, you want a dropdown that lets staff:

  1. Select “All” (to see every visitor for all hosts) or
  2. Pick a specific host’s name (to filter the gallery by that host).

Fetching the distinct host names is simple:

Sort(
    Distinct('Visitor Records', Host.DisplayName),
    Value,
    SortOrder.Ascending
)

But how do you add an “All” option at the top of those results?

❌ Why Common Approaches Fail

Many developers try:

[ {Value: "All"} ] & Sort(
    Distinct('Visitor Records', Host.DisplayName),
    Value,
    SortOrder.Ascending
)
Table({Value: "All"}) & Sort(
    Distinct('Visitor Records', Host.DisplayName),
    Value,
    SortOrder.Ascending
)

Both produce schema mismatches or invalid-argument errors. Power Apps expects each side of the & operator to be a table with the same structure (same column names and types). Distinct() returns a one-column table (Value), but Table({Value:"All"}) is a distinct construct that doesn’t line up neatly.

✅ The Ungroup() Solution

The trick is to use Table() to create a nested table that contains both the literal record and the result of Distinct(), then flatten that nested table back into a single column using Ungroup(). Here’s the magic formula:

Ungroup(
    Table(
      { Value: "All" },
      Sort(
        Distinct('Visitor Records', Host.DisplayName),
        Value,
        SortOrder.Ascending
      )
    ),
    Value
)

Let’s break down each component of this code:

  1. Distinct('Visitor Records', Host.DisplayName)
    • Purpose: Extract unique host names from the Visitor Records list.
    • Benefit: Ensures duplicate host entries don't clutter the dropdown.
  2. Sort(..., Value, SortOrder.Ascending)
    • Purpose: Sorts the distinct host names in alphabetical order.
    • Benefit: Enhances user experience by providing an intuitive, well-ordered list.
  3. Table({ Value: "All" }, ...)
    • Purpose: Manually creates a table with a single record for the option "All" and concatenates it with the sorted distinct host names.
    • Benefit: Provides a universal option that allows users to bypass filtering by a specific host.
  4. Ungroup(..., Value)
    • Purpose: Flattens the combined table into a single-column table by merging all records.
    • Benefit: Ensures the final output is simple and can be easily bound to dropdown controls without any nesting issues.

🛠 Step-by-Step Implementation

1. Insert a Dropdown on your Canvas screen and set its Items property to the Ungroup() formula above.

2. Set the dropdown’s Default property to "All".

3. Reference Dropdown1.Selected.Value when filtering your gallery:

Filter(
    'Visitor Records',
    Dropdown1.Selected.Value = "All"
      || Host.DisplayName = Dropdown1.Selected.Value
)

Why and When Should You Use Ungroup?

  • Flattening Complex Data Structures: When data sources are combined or grouped, columns may end up containing nested tables. Ungroup removes that extra layer, delivering a simplified, single‐level table.
  • Enhancing Control Binding: Many PowerApps controls expect a flat table. By using Ungroup, you ensure that these controls receive data in the proper format, avoiding errors or unexpected behaviors.
  • Improved Data Manipulation: Once flattened, the data is much easier to filter, sort, and manipulate. This leads to cleaner and more maintainable formulas in your app.

Benefits of Using Ungroup in Our Scenario

  • Clean Data Presentation: The final output is a neatly flattened, single-column table containing both the manual "All" record and the dynamically sourced host names—ideal for use in dropdowns.
  • Ease of Use: Flattening the nested table avoids the need for additional parsing or custom functions.
  • Flexibility: This method allows you to easily include more custom records without reengineering the data structure.

Conclusion

The Ungroup function is invaluable when developing in PowerApps, particularly in scenarios like our Visitor Pre-Registration and Check-In System where merging static and dynamic data is essential. By using Ungroup to flatten a nested table, we can ensure that our enhancements—such as dropdown controls for filtering—are robust, user-friendly, and maintainable.

Whether you’re building a visitor management solution or any other application that deals with composite data sources, mastering Ungroup can significantly streamline your development process. Happy PowerApping!

Thursday, February 27, 2025

ModelDrivenFormIntegration in PowerApps: A Deep Dive for Custom Page Integration

ModelDrivenFormIntegration in PowerApps: A Deep Dive for Custom Page Integration

When working with PowerApps Model-Driven Apps, you might need to add a Custom Page to a form.

Recently, someone in a WhatsApp group I’m a part of asked for help:

How can I implement the following in a PowerApps model-driven app? I have a case form and want to add a custom page that, upon loading, retrieves all task records associated with a specific case entity. These tasks should be displayed in a grid, and when I select a task from the grid, I need to edit that task record. Could you provide some insight?

To fetch tasks on page load, I was using Power Fx in the OnVisible property of the custom page.


// Get the Case ID from the navigation context
Set(varCaseID, Param("recordId"));

// Fetch all task records related to this case
ClearCollect(
    colTasks,
    Filter(Tasks, RegardingId = varCaseID)
);
    

Filtering wasn’t working, so I tested with LookUp to check if the Case ID was being retrieved correctly.


Set(
    varSingleTask,
    LookUp(Tasks, 'Regarding (Case)'.IncidentId = varCaseID)
);
    

LookUp did not work either. This is where ModelDrivenFormIntegration comes into play. It acts as a bridge between custom pages and model-driven forms, allowing seamless data transfer and interaction.

What is ModelDrivenFormIntegration?

ModelDrivenFormIntegration is a special PowerApps control that provides contextual information about the form it is embedded in. It helps retrieve form data, interact with records, and update values dynamically within a custom page.

What Does ModelDrivenFormIntegration Do?

  • Passes data from the model-driven form to a custom page
  • Provides access to the currently selected record in the form
  • Allows actions like saving, refreshing, or updating records

Key Properties

Property Description
Item The record currently being viewed/edited
DataSource The table (Dataverse entity) the form is bound to
Mode The current form mode (Edit, New, View)

How to use it in Power Fx

Get Current Record's ID (Primary Key)

ModelDrivenFormIntegration.Item.'IncidentId'

This retrieves the Case ID (IncidentId) from the form. It is useful when filtering related records like tasks or logs.

Get a Field Value from the Current Record

ModelDrivenFormIntegration.Item.Title

This gets the Title field of the current record. Replace Title with any other field name from your entity.

Filter Related Records in a Custom Page

Filter('Tasks', 'Case'.'IncidentId' = ModelDrivenFormIntegration.Item.'IncidentId')

This expression fetches all Case Logs that are linked to the current Case shown in the form.

Check If Form is in Edit or New Mode

If(ModelDrivenFormIntegration.Mode = FormMode.New, "New Record", "Existing Record")

This helps customize behavior based on whether a user is creating a new record or editing an existing one.

Advanced Use Cases

1. Conditional Formatting Based on Data

Use Power Fx to highlight fields based on conditions:

If(ModelDrivenFormIntegration.Item.Status = "Pending", RGBA(255,0,0,1), RGBA(0,255,0,1))

This changes the background color based on the record’s Status field.

2. Trigger a Flow When a Button is Clicked

If you want to run a Power Automate Flow, add a button and use:

PowerAutomateFlow.Run(ModelDrivenFormIntegration.Item.ID)

Replace PowerAutomateFlow with your actual Flow name.

When Should You Use ModelDrivenFormIntegration?

  • Passing data to custom pages from a Model-Driven Form
  • Filtering related records dynamically based on the selected form record
  • Checking form mode for different user actions

Conclusion

Using ModelDrivenFormIntegration, you can deeply integrate Custom Pages with Model-Driven Apps, unlocking powerful capabilities. Whether it's reading form data, modifying fields, or triggering actions, this feature ensures your custom solutions work seamlessly within Dataverse environments.

💡 Next Steps: See my other blog where i have added a custom page to a Model-Driven App Table (entity) form! 🚀

Happy PowerApp-ing! 🎉

Enhancing Case Management in PowerApps

Enhancing Case Management in PowerApps: Fetch and Edit Task Records Using a Custom Page

Today, someone from one of the WhatsApp groups I am a member of asked for help:

How can I implement the following in a PowerApps model-driven app? I have a case form and want to add a custom page that, upon loading, retrieves all task records associated with a specific case entity. These tasks should be displayed in a grid, and when I select a task from the grid, I need to edit that task record. Could you provide some insight?

In this blog post, I’ll walk you through how to add a custom page in a model-driven app for the Case entity and retrieve related Task records dynamically using ModelDrivenFormIntegration. We’ll also display these tasks in a grid and allow users to edit task records upon selection.

Why Use a Custom Page?

Custom pages in PowerApps model-driven apps give flexibility in UI design while still integrating seamlessly with Dataverse. By leveraging ModelDrivenFormIntegration, we ensure the custom page dynamically pulls the related Task records for each Case entity record.

Step 1: Create a Custom Page in PowerApps

  1. Open PowerApps Maker Portal.
  2. Navigate to Apps and select your model-driven app.
  3. Click Edit → Pages → Add page → Select Custom page.
  4. Name the page (e.g., CaseTasksPage).
  5. Click Save and Publish the app.

Step 2: Add a Gallery to Display Task Records

Once inside the custom page, we will use a Gallery control to list all Task records related to the selected Case.

If(
    !IsEmpty(ModelDrivenFormIntegration.Item), 
    Filter(Tasks, regardingobjectid = ModelDrivenFormIntegration.Item.'Case ID')
)

Here,

  • ModelDrivenFormIntegration.Item represents the current Case record.
  • We use Filter(Tasks, regardingobjectid = ModelDrivenFormIntegration.Item.'Case ID') to retrieve only the tasks linked to that Case.

Step 3: Open Task Record for Editing

To allow users to edit a task, we’ll add a Select action inside the Gallery:

If(
    !IsBlank(galTasks.Selected),
    ModelDrivenFormIntegration.OpenForm(
        EntityName."Tasks",
        galTasks.Selected.TaskID,
        FormMode.Edit
    )
)

Here,

  • galTasks.Selected.TaskID retrieves the selected Task record ID.
  • ModelDrivenFormIntegration.OpenForm() opens the selected Task in edit mode.

Step 4: Test and Publish the Custom Page

Final Thoughts

By using custom pages with ModelDrivenFormIntegration, you can seamlessly integrate Tasks into the Case form, making it easier to track, manage, and edit case-related tasks. This approach enhances the user experience by eliminating the need to navigate through multiple forms manually.

🔹 Enhancements consideration:

  • Add more filtering (e.g., based on Task status).
  • Include a button to create new Tasks for a case.
  • Use Dataverse tables for additional customization.

Happy PowerApp-ing! 🎉

Saturday, February 8, 2025

How to Embed a Canvas App Inside a Model-Driven App Using a Custom Page

How to Embed a Canvas App Inside a Model-Driven App Using a Custom Page

Today, someone from one of the WhatsApp groups I am a member of asked for help:

How do I embed a canvas app inside a custom page is it possible .if yes then how can I able to achieve it ..

In this blogpost, I will try to show how to embed a Canvas App inside a Model-Driven App using a Custom Page. I’ll build an Employee Self-Service Portal with advanced features like email notifications and PDF leave confirmations.

Scenario: Employee Self-Service Page with Advanced Features

Employees can:

  • View their leave balance.
  • Submit a leave request.
  • Download a PDF confirmation of their request.
  • Receive email notifications for approval status.

Step 1: Design the Data Model in the Model-Driven App

Before building the app, set up the necessary Dataverse tables (entities).

1️⃣ Create the Leave Requests Table

Go to Power Apps → Dataverse → Tables.

Click New Table, name it Leave Requests.

Add the following columns:

  • Employee Email (Text, Required)
  • Leave Type (Choice: Vacation, Sick, Unpaid, Other)
  • Start Date (Date)
  • End Date (Date)
  • Reason (Multiline Text)
  • Status (Choice: Pending, Approved, Rejected)
  • Number of Days (Whole Number, Required)

2️⃣ Create the Leave Records Table

Click New Table, name it Leave Records.

Add columns:

  • Employee Email (Text, Required)
  • Balance (Whole Number, Required, Default: 20)

3️⃣ Create the Attendance Records Table

Click New Table, name it Attendance Records.

Add columns:

  • Employee Email (Text, Required)
  • Date (Date)
  • Check-in Time (Time)
  • Check-out Time (Time)
  • Status (Choice: Present, Absent, Late)

4️⃣ Create the Employee Profile Table

Click New Table, name it Employee Profile.

Add columns:

  • Employee Email (Primary, Required)
  • Full Name (Text)
  • Phone Number (Phone)
  • Department (Choice)
  • Manager Email (Text)

Save and publish the tables before proceeding to the next steps.

Step 2: Create a New Custom Page in the Model-Driven App

Next we will create a Custom Page in the Model-Driven App. A Custom Page is a special kind of Canvas App that can be embedded inside a Model-Driven App.

1️⃣ Open Power Apps Studio

Go to Power Apps.
Select Dataverse environment.
Click on Apps.
Edit Model-Driven App.
    

2️⃣ Add a Custom Page

Click Add Page → Select Custom Page.
Choose Blank Page and name it Employee Self-Service Page.
Click Create.
    

Step 3: Design the Custom Page (Canvas App)

Now, let’s build the Employee Self-Service Page inside the Custom Page editor.

1️⃣ Add a Welcome Banner

Insert a Label at the top and set the text to:
"Welcome, " & User().FullName & "!"
I am formatting it with a 24px font size and blue color, you can choose your own verbiage and asthetics.
    

2️⃣ Add a Leave Balance Display

Insert a Text Label for the header:
"Your Leave Balance:"
Insert another Text Label to show balance:
LookUp(LeaveRecords, EmployeeEmail = User().Email).Balance & " days"
    

3️⃣ Add a Leave Request Form

Insert an Edit Form [Go to Insert → Forms → Edit Form] and set the Data Source to Leave Requests (Dataverse Table).

4️⃣ Add a Submit Button

Insert a Button labeled "Submit Leave Request".
Set the OnSelect property to:

Patch(
    LeaveRequests, 
    Defaults(LeaveRequests), 
    {
        EmployeeEmail: User().Email,
        LeaveType: Dropdown1.Selected.Value,
        StartDate: DatePicker1.SelectedDate,
        EndDate: DatePicker2.SelectedDate,
        Reason: TextInput1.Text,
        Status: "Pending",
        'Number of Days': DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate) + 1
    }
);
Notify("Leave Request Submitted", NotificationType.Success);


    

5️⃣ Automate Leave Balance Updates in Dataverse

  1. Go to Power Automate.
  2. Click Create → Automated Cloud Flow.
  3. Select When a row is modified (Dataverse) as the trigger.
  4. Set Table Name to Leave Requests, Change Type to Modified.
  5. Add a condition: Status eq 'Approved'.
  6. Use Get a Row by ID to retrieve the employee's leave balance.
  7. Use Compose to calculate:
  8. int(outputs('Get_a_Row_by_ID')?['Balance']) - 
    int(outputs('TriggerBody')?['Number_of_Days'])
  9. Update the LeaveRecords table with the new balance.
  10. Click Save & Test.

Step 4: Automate Email Notifications and PDF Generation with Power Automate

Let’s set up a Power Automate Flow to handle email notifications and PDF confirmations.

1️⃣ Create a Power Automate Flow

Go to Power Automate: https://flow.microsoft.com.

Click on Create → Automated Cloud Flow.

Set the trigger as When a row is added, modified, or deleted (Dataverse).

2️⃣ Configure the Flow

  • Trigger Condition: Set to trigger when Status is updated.
  • Send Email Notification:
    • Add a Send an email (V2) action.
    • Set To as EmployeeEmail from the Dataverse record.
    • Set the Subject as "Leave Request Status Update".
    • Set the Body as:
Dear [Employee Name],

Your leave request from [Start Date] to [End Date] has been updated to [Status].

Regards,
HR Team
    

3️⃣ Generate PDF Confirmation

  • Add an action Populate a Microsoft Word Template (or use OneDrive/SharePoint to create a file).
  • Set placeholders for Employee Name, Leave Dates, and Status.
  • Convert the Word document to PDF using the Convert Word Document to PDF action.
  • Save the PDF in OneDrive or SharePoint.

4️⃣ Attach PDF in Email

  • Add an action Send an email (V2).
  • Attach the PDF file from the previous step.
  • Send it to the employee’s email with the subject "Leave Request Confirmation".

5️⃣ Integrate Flow with Canvas App

Next Steps:

  • Add the Custom Page to the Model-Driven App Navigation
  • Ensure proper licensing and security role for permissions
  • Share the Model-Driven App
  • Refinements

  • Responsive Layout of the Custom Page
  • Redundant Tables: Some tables could be merged into one for simplicity.
  • Data Validation: Add checks for date conflicts and required fields
  • Enhancing Model-Driven App Views with Custom Column Icons

    Enhancing Model-Driven App Views with Custom Column Icons A Hidden Feature That Can Make Your Views Much More User-Friendly I came acro...