Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Extending Microsoft Power Apps with Power Apps Component Framework
Extending Microsoft Power Apps with Power Apps Component Framework

Extending Microsoft Power Apps with Power Apps Component Framework: A complete guide to creating, deploying, and improving your code components

eBook
zł59.99 zł135.99
Paperback
zł169.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Extending Microsoft Power Apps with Power Apps Component Framework

Chapter 1: Introduction to the Power Apps Component Framework

One of the most sought-after new features for developers using Power Apps was the introduction of the Power Apps component framework, an extensibility framework for professional developers to create their own code components that can be natively added to model-driven or canvas apps. This chapter aims to introduce you to the framework and how it improves user interaction with an application. In a step-by-step manner, we will look at the various facets of the Power Apps component framework and end the chapter by preparing our machine for the upcoming chapters.

In this chapter, we are going to cover the following main topics:

  • Overview of the Power Apps component framework
  • Understanding the difference between the Power Apps component framework and HTML web resources
  • Getting to know the licensing requirements
  • Exploring the advantages of the Power Apps component framework
  • Preparing your development machine

Learning some terminology

Before we begin, there is some terminology used throughout the book, and in this section, we are going to get familiar with it.

Dataverse is a platform that not only stores data in a logical manner but also provides security and audit capabilities around data. It provides a rich set of APIs and connectors. It also enables developers to extend the platform to accomplish their custom requirements. It was previously known as Common Data Service (CDS).

Web resources are special files that help extend the Dataverse platform. There are different types of web resources. One such type is HTML, which extends the Dataverse platform by providing the ability to embed HTML components on forms, sitemaps, and dashboards.

Xrm context is an object provided by the Dataverse platform that helps developers to extend the platform by providing access to data, metadata, and some additional functions. Xrm context is crucial to extending the platform as it enables developers to integrate web resources with the platform to fulfill custom requirements.

Now that we understand some of the terminology, let's get an overview of the Power Apps component framework.

Overview of the Power Apps component framework

This section is all about gradually familiarizing ourselves with the framework. Let's first understand what exactly the Power Apps component framework is and why we need it. It is important to understand how the Power Apps component framework evolved before we move on to learning about the differences between the Power Apps component framework and HTML web resources, as well as the licensing requirements and the advantages of using this framework.

What is the Power Apps component framework?

The Power Apps component framework, otherwise known as PCF, is defined by Microsoft as a framework that empowers professional developers and app makers to create code components for model-driven apps and canvas apps to provide enhanced user experience for users to work with data on forms, views, and dashboards. But what does that mean? It means that now professional developers can create widgets that can be configured by the system customizer or an app maker easily, extending the capabilities of any application. Some examples include transforming a numeric field into a slider or transforming a list of appointments into an entirely different visual, such as a calendar.

Originally, it was named Custom Control Framework (CCF) and later renamed to Power Apps Control Framework, but that name did not stick for too long and it was finally renamed to the Power Apps component framework (PCF). Before releasing this framework for public use, Microsoft was using it internally to create a lot of components on a unified interface, one such component being editable grids.

PCF allows professional developers to use a multitude of libraries and services of their choice and add these reusable components to any model-driven or canvas app. Other than providing usability, the framework also provides powerful capabilities for advanced interactions. To facilitate the development of code components, the Microsoft Power Apps CLI tool enables component creation, easy debugging, built-in validation, and testing using a code editor of your choice.

PCF resolves some of the drawbacks we had for a long time with HTML web resources, such as the lack of flexibility and portability, by providing the ability to package a component with parameters. This means your component is abstracted from an environment and made into a truly reusable component. For example, say you want to show a weather forecast depending on the zip code from an entity record. If we had to do this using an HTML web resource, we would have to keep the forecast API information either hardcoded or in a configuration entity. To do the latter would mean an extra line of code. Also, because we want to read the zip code from the entity record, we would have to fetch the Xrm context using the window.parent method. This is simplified using PCF by using the parameters on the control configuration form. With the same example, you can capture the forecast API information as a component property and access the zip code data using the framework's context object, which provides a neat out-of-the-box way to access an attribute's data. We will be looking into this framework's context object further in later chapters.

Note

At the time of writing this book, PCF does not work on on-premises instances.

Now that you understand what PCF is and its history, let's look at who exactly it caters to.

Who is it focused on?

When Microsoft introduced the low-code-no-code platform, there were two terms used within the realm of business applications: citizen developer and professional developer. Citizen developers are not developers in the regular sense, and they may not know a coding language, but they are still involved in the development process through using low-code tools, such as canvas apps, Power Automate, and so on. These tools may not necessarily be straightforward and there is a bit of learning needed to use them. Professional developers are the ones who are more heavily involved in the development process and extend their platforms using various programming languages. These developers may create reusable components that can be utilized by citizen developers.

PCF is targeted more at professional developers, as along with knowledge of the framework, you also need basic knowledge of TypeScript, npm, and the web development process. This framework enables you to create code components that can be used by citizen developers on model-driven or canvas apps. Hence, now more than ever, we need a collaborative effort between citizen developers and professional developers to create holistic and usable systems.

If you are a professional developer with basic knowledge of JavaScript and Dataverse but you do not possess working knowledge of TypeScript or npm, do not worry, as this book will provide ample support for you to understand the basics needed to build a code component.

Note

The code components built using PCF are sometimes also referred to as custom controls.

Next, we will learn the difference between HTML web resources and code components and understand the reasoning behind keeping both HTML web resources and code components.

How are code components different from HTML web resources?

Now, you may wonder, do you need HTML web resources if you have code components? The answer is yes, we still need HTML web resources, and as of today, both have their own distinct ways that offer you full flexibility in customizing your system. For instance, code components can only be tied to a field or a dataset; so, if you have a requirement to add a custom piece of functionality to a dashboard that cannot be accomplished using iFrames or charts, you will still have to resort to HTML web resources.

The following table shows us some of the notable differences between HTML web resources and code components:

Table 1.1 – HTML web resources versus code components

Table 1.1 – HTML web resources versus code components

As you can see from the preceding table, HTML web resources help where PCF lacks and vice versa, providing you with full flexibility in customizing your application. Let's now look at the licensing needs.

Getting to know the licensing requirements

How a code component interacts with an external service determines the licensing scheme for the app that consumes the code component. The two license classifications are as follows:

  • When an app uses a code component that connects with an external service, it becomes premium, and end users need to have a Power Apps license.
  • If code components do not consume an external service, then the usage of such components in an app requires users to at least have a license for Office 365.

    Note

    A code component cannot be used in Dataverse for Teams.

Now that we understand the licensing requirements, let's go through the advantages of using PCF.

Exploring the advantages of PCF

When developing code components using PCF, it is important for you to know some of the advantages of the framework. They are as follows:

  • Access to a rich set of framework APIs that grant capabilities such as managing component life cycles and getting contextual data and metadata information.
  • Seamless server access through a web API, utility, and data formatting methods.
  • Access to device features, such as camera, location services, and microphone.
  • Provides a quickstart template that uses npm packages and webpack.
  • Optimized for performance.
  • Unlike HTML web resources, which get rendered as an iFrame, code components are rendered as part of the DOM, which provides an enhanced and seamless user experience.
  • Developers can utilize Power Apps capabilities to the fullest; for example, they can use the command bar on sub-grids.
  • Based on how code components are created, PCF can support both model-driven and canvas apps. We will be looking at the cases when a code component cannot support canvas apps in later chapters.

These are just some of the advantages of PCF. Let's now look at how to prepare your machine, which will help us develop the code components.

Preparing your development machine

There are some prerequisites you need to install before you can start building the code components that we will be using in this book. In the following subsections, we will look at each of these prerequisites in detail and examine the processes required to get these tools installed.

Node.js or npm

The first prerequisite is Node.js or npm; you do not need both because if you install one, the other gets installed as part of it.

Node.js helps users to build scalable applications using an asynchronous event-driven runtime engine.

npm is an open source JavaScript and TypeScript package registry. It has a command-line interface that enables developers to interact with it.

For installation, browse to https://nodejs.org and choose the latest LTS version available for download. Once the file is downloaded, execute it to install it on your machine:

Figure. 1.1 – Node.js download

Figure. 1.1 – Node.js download

Once the installation is complete, you can check the status by opening a command prompt and running the npm version command, which should show you the npm version installed on the machine.

TypeScript

Once you have installed these prerequisites, you need to make sure you have TypeScript installed on the machine. To check whether TypeScript is already installed on your machine, open the command prompt and execute the following command:

tsc -v

If the response from the command shows a version number, then you already have TypeScript installed on your machine, but if the response states that the command is not recognized, then you need to install TypeScript on your machine.

TypeScript can be installed through npm using the following command:

npm install -g typescript

-g means it is installed on your system globally so that the TypeScript compiler can be used in any of your projects. Once the installation is complete, you can execute tsc -v to confirm it.

.NET Framework

Next, you need to make sure the .NET Framework 4.6.2 developer pack is installed on your machine. To check whether 4.6.2 version is already installed on your machine, do the following:

  1. Open Visual Studio Installer. If you do not have Visual Studio Installer, then you can download the latest version of Visual Studio from https://visualstudio.microsoft.com/downloads.
  2. From the More option for the latest version of Visual Studio, select Modify, which will bring up the Installation details window.
  3. Make sure the ASP.NET and web development option is checked.
  4. On the right-hand panel, under ASP.Net and web development, confirm that .NET Framework 4.6.2 development tools is checked. If it is not installed, then check the box and click on the Install while downloading button, as seen in the following screenshot:
Figure. 1.2 – .NET Framework 4.6.2 installation

Figure. 1.2 – .NET Framework 4.6.2 installation

Visual Studio Code

While you can use any preferred integrated development environment, for the development in this book, we are going to use Visual Studio Code.

Visual Studio Code is a free source code editor made by Microsoft for Windows, Linux, and macOS. Its features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git.

If you do not have Visual Studio Code installed on your machine, you can install it from https://code.visualstudio.com/download.

Power Apps CLI

The most important tool in enabling a developer to interact with PCF and empowering them to create, test, debug, and deploy code components is Power Apps CLI. To download it, browse to https://aka.ms/PowerAppsCLI. Once downloaded, install it on your machine.

Note

Currently, Power Apps CLI is only supported on Windows 10.

To confirm the installation, open the command prompt and run the pac command. It should show an output as follows:

Figure 1.3 – Executing the pac command

Figure 1.3 – Executing the pac command

Once your machine has been prepared with all the prerequisites, you need to download the example library.

Downloading the example library and using the practice questions

Throughout this book, you will be creating some sample controls, and to help you validate those controls, a library has been published on GitHub for you to download.

To download the library, navigate to https://github.com/PacktPublishing/Extending-Microsoft-Power-Apps-with-Power-Apps-Component-Framework.

In this book, at the end of each chapter, you will find questions to test the knowledge and skills you have acquired. Each question will show you the points you will earn if you answer it correctly. There are 5,000 points to be earned overall. The answers to those questions can be found at the end of the book.

At this point, you should have all the tools and content you need to build your own code components throughout the book.

Summary

Power Apps component framework is the next level of development framework, enabling developers to extend any type of Power Apps app. We introduced PCF, looked at the key differences between code components and HTML web resources, learned about the licensing requirements, and talked about PCF's advantages. We ended the chapter by learning about the installation processes for all the prerequisites of the book to set ourselves up for the upcoming chapters.

In the next chapter, we will look at the Power Apps CLI tool, which helps in the initialization of various projects.

Test your knowledge

  1. Are HTML web resources still needed when we can just use code components built using PCF? (100 points)

    a. Yes

    b. No

  2. When does an app that has implemented a code component built using PCF need a premium Power Apps license? (100 points)

    a. When a code component does not use an external service

    b. When a code component uses an external service

  3. What is the one crucial application that you need to install in order to prepare your development machine for building code components? (200 points)

    a. Visual Studio Code

    b. Power Apps CLI

Further reading

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Understand how to extend Power Apps' capabilities
  • Enhance your skills with the help of practical code components used throughout the book
  • Overcome common challenges, avoid pitfalls, and improve your code

Description

Power Apps Component Framework is used by professional developers to extend the capabilities of model-driven and canvas apps. Extending Microsoft Power Apps with Power Apps Component Framework will take you through the basic as well as advanced topics using practical examples. The book starts by helping you understand the fundamentals of the framework, its lifecycle, and the tools that you'll use to build code components using best practices and file management guidelines. You'll then learn how to extend Power Apps step by step and apply the principles and concepts covered in the book to build code components for field type attributes. The book covers different ways of debugging code components and guides you through the process of building code components for datasets. You'll also explore the functions and methods provided by the framework to enhance your controls using powerful sets of libraries and extensions. As you advance, you'll get to grips with creating and managing authentication profiles, discover different ways of deploying code components, and configure code components in model-driven and canvas apps. Finally, you'll learn some of the important features of the framework and learn modern web development practices. By the end of this Power Apps book, you'll be able to build, debug, enrich, and deploy code components confidently.

Who is this book for?

This book is for developers who are looking to build advanced skills for extending the capabilities of Power Apps. Basic knowledge of Power Apps and web development is necessary to get started with this book.

What you will learn

  • Understand the fundamentals of Power Apps Component Framework
  • Explore the tools that make it easy to build code components
  • Build code components for both a field and a dataset
  • Debug using test harness and Fiddler
  • Implement caching techniques
  • Find out how to work with the Dataverse Web API
  • Build code components using React and Fluent UI controls
  • Discover different deployment strategies

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 26, 2021
Length: 318 pages
Edition : 1st
Language : English
ISBN-13 : 9781800564916
Vendor :
Microsoft
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Feb 26, 2021
Length: 318 pages
Edition : 1st
Language : English
ISBN-13 : 9781800564916
Vendor :
Microsoft
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 573.97
Workflow Automation with Microsoft Power Automate
zł221.99
Extending Microsoft Power Apps with Power Apps Component Framework
zł169.99
Microsoft Power Apps Cookbook
zł181.99
Total 573.97 Stars icon

Table of Contents

17 Chapters
Section 1: Fundamentals of the Power Apps Component Framework Chevron down icon Chevron up icon
Chapter 1: Introduction to the Power Apps Component Framework Chevron down icon Chevron up icon
Chapter 2: Power Apps CLI Chevron down icon Chevron up icon
Chapter 3: Community Tools and Resources Chevron down icon Chevron up icon
Chapter 4: Project Overview and the Component Life Cycle Chevron down icon Chevron up icon
Section 2: Building and Managing Code Components Chevron down icon Chevron up icon
Chapter 5: Code, Test, and Repeat Chevron down icon Chevron up icon
Chapter 6: Debugging Code Components Chevron down icon Chevron up icon
Chapter 7: Authentication Profiles Chevron down icon Chevron up icon
Chapter 8: Introduction to the Dataverse Project Chevron down icon Chevron up icon
Chapter 9: Configuring Code Components in Power Apps Chevron down icon Chevron up icon
Section 3: Enhancing Code Components and Your Development Experience Chevron down icon Chevron up icon
Chapter 10: Diving Deep into the Features Provided by PCF Chevron down icon Chevron up icon
Chapter 11: Creating Advanced Dataset Code Components Chevron down icon Chevron up icon
Chapter 12: Enriching Your Dev Experience Chevron down icon Chevron up icon
Answers to Knowledge Tests Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(14 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Angela Sawh Oct 07, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This text book provides a very comprehensive description about creating components using Power Apps. I have been able to implement the process of setting up the environment and developing a component without issue.
Amazon Verified review Amazon
Betim Beja Jun 06, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book published on February 2021 still holds strong value even though the platform has evolved. Danish did a great work in giving a hand to anyone starting PCF Development. Definitely a must-read book even for experienced developers.
Amazon Verified review Amazon
Nicholas Castro Jul 28, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book covers all of the bases when it comes to PCF development! My favorite parts of the book are the test your knowledge multiple choice questions at the end of each chapter, the chapter on debugging which provided multiple ways to debug and test code components and the final section of the book that shows you how to create production ready PCF components and enhancing your development experience. This book is a must have!
Amazon Verified review Amazon
Placeholder Jul 09, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Probably the best content available for anyone who is not only looking to get started in building PCF controls but also is looking to enhance their skills. Beginner to a pro, the book has it everything that a developer would need to simply accomplish the job. Kudos to Danish for the amazing work
Amazon Verified review Amazon
R. Birkelbach Mar 22, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A comprehensive explanation of PCF development, considering all aspects like: project setup, customizing, debugging, testing, deployment, lifecycle management. The author is also a community contributor, so you get to know from the first hand about community resources but also about the official ones.From experience I know that PCF sdk is only a starting point, but you will need to answer a lot of questions by yourself. This book gives you the answers, helps you to understand the principles, but also to deep dive extended techniques and topics about the field and dataset type components. The learned content is demonstrated by examples and gives you the chance to test your knowledge after each chapter.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.