Thursday, 27 May 2021

PowerApps Portals Build Tools - An Azure DevOps Extension to Automate Portal Deployment

 


About PowerApps Portals Build Tools

This tool empowers developers to enable CI/CD (Continuous Integration/Continuous Deployment) of portal configuration. You can use this tool to check-in the portal configuration to source control and move the portal configuration to any environment using Power Apps CLI.

For more details about Power Apps CLI support for Power Apps Portal. You can check these articles:

TaskDescription
Portal Tool InstallerThis tasks install pre-requisites tools like node.js and npm to connect, authenticate, download, and upload the portal configuration
Export Portal ConfigurationThis task exports the portal configuration from the power platform environment and saves it in the source control.
Import Portal ConfigurationThis task imports the Portal configuration in the power platform environment
Steps to configure
Step 1 - Install the extension in your Azure DevOps Instance
  1. Create a build pipeline in Azure DevOps and find the tool with the name: "Power Apps Portal Build Tools".
  2. Click on "Get it free" to get this tool installed in your Azure DevOps instance.



Step 2 - Portal Tool Installer

Portal Tool Installer task is used to install all prerequisites software and tools like npm, node.js, etc in Azure DevOps VM. These tools and software are required to connect, authenticate, download, and upload the portal data from/to your Power Platform environment.



Step 3 - Export Portal Configuration

Export Portal Configuration task is used to export(download) the portal configuration (form, list, webpages, content snippet, etc) from your Power Platform environment and store it in the source control. In order to use this task in your build pipeline(CI), You need to pass some mandatory information like D365 instance URL, application Id, client secret, tenant id, website id, and the folder path of your source control where you want to save the portal configurations.

Here are the mandatory details that you need to provide:

  • Dynamics 365 URL: https://.crm.dynamics.com
  • Application Id: Register an Azure AD app in azure and capture this value from there
  • Client Secret Key: Register an Azure AD app in azure and capture this value from there
  • Azure Tenant Id: Capture this value from your Azure AD
  • Portal Website id: Capture this value from Dynamics 365 instance, where your portals are installed
  • Save export data: Repository path where you want to store your portal configuration data. For Ex. if you have a folder in the repository with the name Power-Platform-Solution and inside that there is one more folder called PowerApps-Portals, where you want to export the portal configuration, then this parameter value must be: Power-Platform-Solution\PowerApps-Portals

Step 4 - Commit data to source control

Once you export the portal configuration, it is currently available on your Azure DevOps virtual machine. You need to commit that data to your source control in the Master branch. To do that, you should add a Powershell task and add the following script.

Note: In the git add the command (4th line in the script, as shown below), give the folder path where you want to store the portal configuration in the repository

Step 5 - Import Portal Configuration

Import Portal Configuration task is used to import(upload) the portal configuration (form, list, webpages, content snippet, etc) to your Power Platform environment. In order to use this task in your release(CD) pipeline, You need to pass some mandatory information like D365 instance URL, application Id, client secret, tenant id, and the folder path of your source control where you have exported/stored the portal configurations.

Here are the mandatory details that you need to provide:

  • Dynamics 365 URL: https://.crm.dynamics.com
  • Application Id: Register an Azure AD app in azure and capture this value from there
  • Client Secret Key: Register an Azure AD app in azure and capture this value from there
  • Azure Tenant Id: Capture this value from your Azure AD
  • Portal data: Repository path, where you had stored the portal configuration using Export Portal Configuration task. For Ex: if your portal configuration is stored in \Power-Platform-Solution\PowerApps-Portals\Starter-Portal folder, then you should choose the Starter-Portal folder in the folder path (as shown below)


Demo and Usage


Monday, 17 May 2021

PowerApps - Highlight First Record in Canvas App List Gallery


Introduction

Hey Everyone!

I hope you all had fun and great learning this weekend in PowerApps Developer Bootcamp.

I would like to express my sincere appreciation to all the Speakers and Participants who generously helped us make this event come together to become a success 💪

During the event, one of our participants had a question about Highlighting the first record in the Canvas App List Gallery control. I found this requirement quite interesting and tried to google it to check if someone else has already been implemented this before or not. However, I couldn't find anything on the internet.

So, I thought of implementing it using my experience and knowledge of PowerApps.

Today in this blog post, I am going to share a #PowerGuideTip32, where I'll show you a simple trick to highlight the first record in the List Gallery.

So let's get started...


Implementation

Step 1 - Add a List Screen in your Canvas App.

Step 2 - Connect with Data Source to display the records

Step 3 - Add a Rectangle Icon to the screen (above the Gallery control).

(a) Make sure this Rectangle icon must be added outside your List Gallery control. To do that, you can select the Gallery control from the left navigation panel and drag it down a bit and then place the Rectangle icon right above the Gallery (as shown below)

(b) Make sure the Height and Width of the Rectangle are similar to List Gallery's first record (as shown below). So that it can cover the complete information being displayed in the record.

(c) Change the Background color of the Rectangle as per your need.

Step 4 - Right click on Gallery control from the left navigation panel and choose Reorder > Bring to front

The idea to do this setting is to set the Rectangle Icon in the background of the Gallery's first record.

Step 5 - Now drag and adjust the whole Gallery, so that the first record of the Gallery control could appear on top of Rectangle (As shown below)

Step 6 - Run the app and see the result.


Demo of Implementation



Important Note: In this example, I haven't used any query or formula like Lookup(...), First(...), and Filter(...) expressions in order to find the first record of the table. This is just a simple example to showcase the capabilities of out of box controls of Canvas App in order to highlight the first record of List Gallery, 



I hope you found this Tip useful.

Stay tuned for the next Tip - #PowerGuideTop33.

Monday, 3 May 2021

PowerApps - Get Canvas App Logged-In User Role from Dynamics 365



Introduction

Hi Everyone,

Hope you are doing great and staying safe!

Today, in this blog post I am going to share #PowerGuideTip31, where I'll demonstrate how to read Dynamics 365 security role in PowerApps Canvas App.

There are many business use cases, where we need to design an App based on the Dynamics 365 security role. One of the best examples is:

Role-based Canvas App, where we need to navigate the user to different-2 screens or perform different process/flow based on the role assigned in the Dynamics 365 application.

I have already been demonstrated this feature in my earlier blog post, In that post, I had used Power Automate to get the Dynamics 365 Security Role in Canvas App. However, today I am going to retrieve it directly in Canvas App without using any external components.

Let's get started...

I have designed a Canvas App that allows -
  • Event Organizers to manage the organization events.
  • Speakers to submit their session.
  • Participants to register for an event.

Implementation

Step 1: Design a Login Screen


Step 2: Use an expression to retrieve Canvas App logged-in user's security role from Microsoft Dataverse

I am using the following expression (Microsoft Power Fx) on OnStart property of the Canvas App.
That means, every time when you open the app, all security roles assigned to the logged-in user will get automatically stored in the Canvas App Collection.

ClearCollect(UserRoles, (LookUp(Users,domainname = User().Email).'Security Roles (systemuserroles_association)').Name)

Here User().Email - returns the logged-in user email address.

LookUp(Users,domainname = User().Email) - Retrieve User from Office 365 whose email address is equal to logged-in user email address

'Security Roles (systemuserroles_association)'),Namewill return the name of all security roles assigned to the logged-in user.

Finally, I am storing the list of all security roles in Collection, so that I can read it throughout my app.


Important Note: App OnStart event will not trigger when you play/run the app from Power Studio Editor. Hence, you won't see any value stored in the Collection. To do that, you need to manually trigger the OnStart event by clicking on Run OnStart (see below).





Step 3: Restrict Canvas App user's login based on security role

Once you have the security roles of the logged-in user, the next thing you need to write the expression on Login Screen to check whether a user has sufficient privileges to access the app or not.

To do that, I have used the following expression on click of 'Event Organizer' control

If(IsBlank(LookUp(UserRoles,Name="Event Organizer")),Navigate(RoleErrorMessage,ScreenTransition.CoverRight,{rolemissing:"Event Organizer"}),Navigate(HomeScreen))

Explanation: Here, I am checking whether the canvas app collection has an Event Organizer role in the list. If it returns blank, then redirect the user to Error Screen else redirect the user to Home Screen.

And, using the following expression on click of 'Participants control

If(IsBlank(LookUp(UserRoles,Name="Participant")),Navigate(RoleErrorMessage,ScreenTransition.CoverRight,{rolemissing:"Participant"}),Navigate(HomeScreen))

Explanation: Here, I am checking whether the canvas app collection has a Participant role in the list. If it returns blank, then redirect the user to Error Screen else redirect the user to Home Screen.




Step 4: Test and Demo



Useful Tip

In the above example, I have retrieved the user's security role on the canvas app OnStart event and stored it in the Collection. Afterward, I am using these roles to design a role-based canvas app, However, you might also have a requirement to show the list of logged-in user roles in the Canvas App Screen. To do that, perform the followings steps:

Add a List type of Screen from the Screen List




Set the 'items' property of the list screen to the Collection name (created in Step 2)





I hope you found this PowerGuideTip helpful.

Stay tuned for #PowerGuideTip32

Sunday, 2 May 2021

Canvas Apps - Auto populate Option Set value in the Canvas App Form


Introduction

Hi Everyone,

Hope you are well and staying safe!

In today's #PowerGuideTip30, I will show you how to auto-populate or set value in Option set field in Canvas App.

I have designed a Canvas App for Event Management purposes, where I have added a screen that the Event Organizer uses to create an Event. This screen has an Option Set field called 'Event Status' that shows the status of the event.

I don't want to allow the Event Organizer to set the Event Status value manually and want to auto-populate its value to 'Submitted' instead.



Solution

To auto-populate value in Option Set value or Set value in Option Set value you should use Choices() expression.
  • The Choices function returns a table of the possible values for a lookup column.
  • Use the Choices function to provide a list of choices for your user to select from. This function is commonly used with the Combo box/ Drop Down control in edit forms.

Syntax

Choices( column-reference )

column-reference – Required. A lookup column of a data source or Option Set Field column. Don't enclose the column name in double-quotes. The reference must be direct to the column of the data source and not pass through a function or control.

Implementation

Choices('Event Status (Events)'.Submitted)

where 'Event Status (Events)' represents the Event Status column of the Event table in Microsoft Dataverse and Submitted is the Option set value that I want to auto-populate.



Note: I want to auto-populate the option set value, hence I have used the Choices(....) expression directly on the items property of Combo box. If you want to set the value on button click then you can use the same expression on onselect property of button control.

Useful Reference





I hope you found this PowerGuideTip helpful. 

Stay tuned for #PowerGuideTip31

Thursday, 8 April 2021

Quick guide to use PCF Controls (Custom Code Components) in PowerApps Portals


Introduction

Hi Everyone,

I hope you are well, staying safe and healthy.

Today I am extremely happy to share the recent Microsoft update, that Custom Code Components (PowerApps Component Framework Controls) or PCF Controls are now supported in PowerApps Portals.

For those who do not know about Custom Code Component or PCF Controls, Please bear with me, because In today's PowerGuideTip29, I am going to share a quick guide to use the custom code components in PowerApps Portals.

What is Custom Code Component or PCF Controls?
  • Custom controls let you transform fields that traditionally contain text into visualizations. Similarly, you can use custom controls to transform datasets, such as a view, to display in a more visual rendering rather than a list of records. 
  • Custom controls can appear as visualizations on forms, dashboards, views, and homepage grids. You can set one type of custom control to appear in the web browser client while having a different custom control appear in your Dynamics 365 for Customer Engagement phone or tablet mobile apps. For example, you could use a number input custom control for a field in web browser clients and a slider custom control for the phone app. 
  • After the customization is published, users can fully interact with the control to change the value, such as by sliding the control when using the linear slider custom control. Changes are automatically saved when the form is closed just as they are when the user changes a traditional field on a form.


How many types of Custom Controls are available in the Model-driven app?
  • You can use a rich set of additional controls to create a more touch-friendly experience on model-driven apps. These include sliders, switches, multimedia players, input masks, calendars, and other controls.
  • You can find the list of all OOB Custom Controls here.

Can I create my own Custom Control (PCF Controls)?

Yes, of course, you can create your own Custom Controls as well based on your business needs. There are few PCF Champs out there, who have designed so many useful and wonderful custom controls. You can download these controls and can start using them.

You can find the PCF Gallery here

Check this article for step by step guide to create your own custom controls.


How to use Custom Control in PowerApps Portals?

You need to perform the following steps in order to use the Custom Control in PowerApps Portals.

Pre-requisites:
  • PowerApps License or Trial Instance
  • System Admin rights
  • Portal version must be  9.3.3.x or higher.
  • Your starter portal package must be 9.2.2103.x or higher.
Step 1 - Build and package your code component. Check here
or
Step 1 - Use the existing custom control

Step 2 - Add the custom control to a field in the Model-driven app





Step 3 - Create Basic Form in Portals
  • For demonstration, I have created a new weblink (My Account) under Profile Navigation Web Link sets and associated it with My Account Web Page. Anf finally I have associated the My Account web page with the My Account Basic form.
  • In My Account Basic Form, I am displaying the portal logged-in user account details. Hence, I have chosen Record Associated to Current Portal User  as RecordSource Type and took form in Edit mode, so that the portal user could update their account details






Step 4 - Create Basic Form Metadata for each Custom Control field in Basic Form

For demonstration, I have used custom controls on the following highlighted fields.


To display the custom control applied on the model-driven app forms field, you need to create a Basic Form metadata for each field and set its Control Style property to 'Code Component' as highlighted below 



Step 5 - Configure Entity Permission for Web Resource table


Associate appropriate Web Role to the Table Permission. I want to display the Custom Controls to all Authenticated Users. Hence I have associated Authenticated Web Roles to the Table Permission.



Step 6 - Clear Portal Cache (or Sync Configuration) and Test Custom Controls on Portals.




Useful Source & References







Hope you found this article helpful.

Stay tuned for the next PowerGuideTip30.

Monday, 22 March 2021

PowerApps - Share Canvas App with External Users



Introduction

Have you ever got a need to share your Canvas App with external organization users? It's a very common business requirement, where you may want to share your app with external users.

For example, You are designing a Canvas App for the Sales Person who works in your organization. However, there are some users like external business partners, vendors, contractors, etc who are not actually part of your organization but they still work for you, and therefore you want them to access your canvas apps.

There are various organizations like Uber, Amazon, Subway, Macdonald, etc who work in the same fashion. They not only work with the users who are part of their organization but also work with their vendors and partners as well.

Today, I am going to share #PowerGuide28 where you'll learn how to share your app with external organization users using the Azure AD B2B collaboration.


What is Azure AD B2B?

Azure Active Directory (Azure AD) business-to-business (B2B) collaboration is a feature within External Identities that lets you invite guest users to collaborate with your organization. With B2B collaboration, you can securely share your company's applications and services with guest users from any other organization, while maintaining control over your own corporate data. Work safely and securely with external partners, large or small, even if they don't have Azure AD or an IT department.
A simple invitation and redemption process lets partners use their own credentials to access your company's resources.

With Azure AD B2B, the partner uses their own identity management solution, so there is no external administrative overhead for your organization. Guest users sign in to your apps and services with their own work, school, or social identities.
  • The partner uses their own identities and credentials; Azure AD is not required.
  • You don't need to manage external accounts or passwords.
  • You don't need to sync accounts or manage account lifecycles.

Pre-Requisites
  • Azure Active Directory  Subscription (Trial is also fine)
  • Power Platform Environment (Trial is also fine)
  • Canvas App (create a new app or use an existing one that you want to share with external users)

Solution Design


Implementation Steps

Go to Azure Portal https://portal.azure.com and Open Active Directory.



Click on Users from the left panel




Click on + New guest User


Choose the Invite user option and fill out all external user details to whom you want to share the canvas app. and hit the Invite button





Open newly created guest user


Click on Licenses from the left panel.


Click on +Assignments and assign an appropriate license to the guest user.


Go to https://make.powerapps.com and share the canvas app with the guest user.



Important Note: Guests can only be assigned the User role, and not the Co-owner role, for apps shared with them. That means, they cant edit the app, they can only run the app.


Test and Demo

Open the invitation email and Accept the Invitation.



Open the app that is being shared with you.




Considerations and limitations for guest access
  • Guests can only be assigned the User role, and not the Co-owner role, for apps shared with them.
  • Power Apps can't recognize guests that authenticate by using Azure AD direct federation or email one-time passcode authentication.
  • Power Apps per-app plans are scoped to apps in a specific environment, so they can't be recognized across tenants.

Useful Resources





Hope you found this Tip helpful

Stay tuned for #PowerGuideTip29

Cheers
Blogger Widgets