[Step by Step] Model Driven App | Grids | Navigate to custom page on row click

By default, performing any of the following grid actions opens the table record:

  • Double-clicking the data row, or selecting the primary column link in the row.
  • Selecting a data row, and then pressing the Enter key.
  • On a touch-enabled device, selecting a data row.

In this article, lets see how to override the default grid click behavior and navigate to a Custom Page. Same approach can be used to navigate to custom URL, show alert etc…

Before jump on to implementing override default behavior, lets understand how the same requirement can be achieved using ribbon button.

Conventional way of achieving this requirement:

Assume that you would want to redirect to custom url (i.e., Google, Bing, etc…) from the Main Grid. One common approach would be:

  • Add a custom jScript function with a desired navigation logic upload as a webresource.
  • Add a ribbon button on grid and map the jScript function.
  • Select the grid record(s) and click the button which will redirect you to the custom url.

In the above approach, the overhead is every time you have to select record in grid and click the ribbon button.

With the ‘override default behavior’ approach would be pretty much same except you don’t need to click the ribbon button everytime.

Using override default behavior:

Let me explain the override default behavior of main grid, by redirecting to a custom page on click of grid row by following these steps.

Create a custom page:
  • As we will be redirecting to a custom page on grid click, first lets create a custom page.
  • I’ve created a simple custom page with ‘Account Name’, ‘Account Number’ fields and a ‘Back’ button.
  • Copy the ‘Name‘ of the Custom Page, which we would using in the next steps.
  • Next, you must add your ‘Custom Page’ to the Model Driven App using editor.

Create a webresource:

We will be adding the navigation to ‘Custom Page’ logic in jScript function. If you want to navigate to custom url or display alert just put the appropriate logic in this jscript function.

  • Create a jScript file and copy following ‘openCustomPage‘ function.
    • Set ‘name’ as the ‘Name‘ of the Custom Page copied in previous step.
  • Save this jScript file as a webresource.

Create a new ribbon button

We need to add a button in this ‘override default behavior’ approach as well but with slight changes.

The placement of the button is important. As we want to override the ‘Main Grid’ behavior, we need to add a new button on the ‘Main Grid’.

If you want to override the Contacts subgrid behavior on the Accounts form, you need to add the new button on to the contact form.

Lets use Ribbon Workbench to add a new button on ‘Account’ Main Grid.

  • Once you add a button, create a command definition with Mscrm.OpenRecordItem as the ID.
    • This is the key. The application looks for the Mscrm.OpenRecordItem command ID, when you try to open a record from the grid and if one is present, will execute the custom action instead of performing the default behavior of opening the table record.
  • Add a ‘Custom Javascript Action’ to the command and and include the CrmParameter with the value SelectedControlSelectedItemReferences.
  • Following is the ‘RibbonDiffXml’ for your reference.
<?xml version="1.0" encoding="utf-16"?>
<RibbonDiffXml xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <CustomAction Id="raj.Mscrm.OpenRecordItem.CustomAction" Location="Mscrm.HomepageGrid.account.MainTab.Management.Controls._children" Sequence="65">
        <Button Alt="$LocLabels:Mscrm.OpenRecordItem.Alt" Command="Mscrm.OpenRecordItem" Id="Mscrm.OpenRecordItem" LabelText="$LocLabels:Mscrm.OpenRecordItem.LabelText" Sequence="65" TemplateAlias="o3" ToolTipTitle="$LocLabels:Mscrm.OpenRecordItem.ToolTipTitle" ToolTipDescription="$LocLabels:Mscrm.OpenRecordItem.ToolTipDescription" />
    <RibbonTemplates Id="Mscrm.Templates" />
    <CommandDefinition Id="Mscrm.OpenRecordItem">
      <EnableRules />
      <DisplayRules />
        <JavaScriptFunction FunctionName="openCustomPage" Library="$webresource:raj_account_js">
          <CrmParameter Value="SelectedControlSelectedItemReferences" />
    <TabDisplayRules />
    <DisplayRules />
    <EnableRules />
    <LocLabel Id="Mscrm.OpenRecordItem.LabelText">
        <Title description="Open Record Item" languagecode="1033" />

Note: You can enable or disable the newly created button; doing either will still override the open default behavior.

  • Publish the Ribbon changes.
  • That’s all needed. If you notice in both ‘conventional’ and ‘override default behavior’ approaches, the ribbon button is common but the ‘override default behavior’ does not require you to explicitly click the button.

  • Refer this Microsoft Docs article for more details.


Azure DevOps | Power Platform Build Tools | WhoAmI | Capture Environment ID

Azure DevOps along with Power Platform Build Tools results a healthy Power Platform ALM.

In this article, I will explain how to use Power Platform WhoAmI task and capture the ‘Environment ID’.

What is PowerPlatformWhoAmi task:

  • Verifies a Power Platform environment service connection by connecting and making a WhoAmI request.
  • This task can be useful to include early in the pipeline, to verify connectivity before processing begins.

YAML snippet of WhoAmi:

Following is the YAML snippet which we would need to include in pipeline.

- task: microsoft-IsvExpTools.PowerPlatform-BuildTools.whoami.PowerPlatformWhoAmi@0
  displayName: 'Power Platform WhoAmI'

#   Service Principal/client secret (supports MFA)
    authenticationType: PowerPlatformSPN
    PowerPlatformSPN: '{My service connection}'
  • This is how the pipeline YAML looks like.
    • Please note that we must have “PowerPlatformToolInstaller” task before executing “PowerPlatformWhoAmi” task.

Output of PowerPlatformWhoAmi:

  • When you run the pipeline, you would get following outcome for ‘PowerPlatformWhoAmi’.
  • In the output, there is this useful ‘Organization Information’ (Highlighted above) like Org ID, Unique Name, Environment ID etc…

Capture the ‘Environment ID’:

  • As we noticed, in the output of PowerPlatformWhoAmi, we could see useful ‘Organization Information’.
  • PowerPlatformWhoAmi output will be persisted in “BuildTools” Environment Variables.
  • To capture the ‘Environment ID’ use this convention $(BuildTools.EnvironmentId).
  • Use ‘echo’ to test the EnvironmentId as shown below.
  • Once you run the pipeline, you should see the EnvironmentId. As $(BuildTools.EnvironmentId) is an Environment variable, you can use in subsequent pipelines as well.


[Step by Step] Power Apps portals | Version Control website using Power Platform CLI

In this article, lets see how to version control the Portal website components using Power Platform CLI Portal commands.

What is Version Control

  • Version control, also known as source control, is the practice of tracking and managing changes to software code.
  • Version control software keeps track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members.

Lets start working with Portal CLI with prerequisites.


Before we jump on to CLI, lets see how portal components can be edited from maker portal.

Edit Portal Website from Maker Portal

Once your Portal application created

  • Click on the portal app.
  • You will be redirected to your portal website as shown below.
  • If you notice, portal website is collection of many components (i.e., Web Pages, Lists, Files, etc…). You can edit the web site by using ‘Edit’ option directly from maker portal.
  • You will be redirected to Portal editor and can edit the components.

Challenges with editing Website directly from Maker Portal

As detailed in above section, you can edit the website directly from Maker Portal but at the cost of following challenges.

  • Its not version controlled. Meaning, if I want to revert a file with content from last stable release, it not possible with out version control.
  • As a Pro developer, you would feel comfortable editing webpage as html file than in the portal editor.

Use Power Platform CLI with portals

Lets see how we can solve versioning using CLI.

  • Open a new ‘Terminal’.
  • As a first step, you need to connect to your Dataverse environment by executing following command.
    • pac auth create -u {Environment_url}
  • Get the list of available Portals by executing following command.
    • pac paportal list
  • Copy the ‘WebSiteId’ as highlighted above.
  • Now download the website components using following command.
    • pac paportal download –path [PATH] -id [WebSiteId]
  • Website contents gets downloaded and saved locally as below.
  • Now, open this folder using VSCode and open the components.
  • Lets go ahead and edit the ‘Home’ web page content.
  • Upload the modified website components using following command.
    • pac paportal upload –path [Folder-location]
  • The upload only happens for content that’s been changed. In the above example, since the change is made to a webpage, content is uploaded only for the adx_webpage table.
  • Now, lets refresh the portal website and you should see the modified text.
  • If you dont see the changes, you can clear the server-side cache as below.
    • Navigate to the URL as follows: <portal_path>/_services/about.
    • Select Clear Cache.

Advantages of CLI for portals development

  • We can commit the website components to any of the version control tools like Azure DevOps, GitHub.
  • We can now use offline-like capability for portals customization by making changes to the portals content. And once all customizations or changes are saved, upload them to the portal.
  • Helps integrate seamlessly with any source control tools, such as “git”
  • Easily set up CI/CD pipelines


  • Portals support for Power Platform CLI is limited to the tables listed here.


Categories: Portals Tags: , ,

[Code Snippet] PowerShell | Azure DevOps | Query Variable Group using API

In Azure DevOps, Variable groups store values and secrets that you might want to be passed into a YAML pipeline or make available across multiple pipelines.

Variable Group is a collection of variables with Name and Value pair.

Below is my variable Group ‘BillingSystemDictionary’ with 3 variables in my DevOps organization ‘RajeevPentyala0011’ and project ‘Demo’ (These details are required in PowerShell script).

In DevOps pipeline scenarios, you may need to fetch the variables under a variable group. Following is the PowerShell script which calls DevOps API and fetch variables by variable group name.

    # Form API authentication Header
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("Authorization", "Bearer $(System.AccessToken)")
    $headers.Add("Content-Type", "application/json")

    # Pass Variable Group Name and read variables
    $variableGroupName = "BillingSystemDictionary"
    # 'projectid' pattern is https://dev.azure.com/{organization_name}/{projectname}
    $projectid = "https://dev.azure.com/RajeevPentyala0011/Demo"

    $variableGroupGetUrl = "$projectid/_apis/distributedtask/variablegroups?groupName=$variableGroupName*&queryOrder=IdDescending&api-version=6.0-preview.2"

    $queryResponseObject = Invoke-RestMethod -Uri $variableGroupGetUrl -Method GET -Headers $headers
    # $queryResponseObject will be of type pscustomobject
    # To fetch the variable value of "isactive"
    $variableName = "isactive"
    $variableValue = $queryResponseObject.value.variables.$variableName.value
    Write-Host "$variableName value is $variableValue"


Categories: CRM, DevOps Tags: , , ,

Power Apps | Application Insights | Query Telemetry data

Recently while troubleshooting as issue which was only occurring for a particular user, there was this question from a customer on “Determining how this user is accessing their system”.

To simplify the question, assume that you have a Model Driven App and end users might access it from following modes and you need to determine using which mode a particular User accessed the application in last 24 hours.

  • Different browsers
  • Plug-in Registration
  • XRMToolBox
  • Powerautomate
  • Postman
  • etc…

Coming back to troubleshooting, since the issue occurring for only a User, it would be a great help to fetch User access details like (Client OS, Region, Host Type, User Agent etc…) to narrow down the issue and provide fix.

In this article lets see how Application Insights telemetry data helps us troubleshoot issues related to application slowness, intermittent issues and many more.


Once the prerequisites are fulfilled, we need to set up Applications Insights for Power Platform environment.

Configure Application Insights for Power Platform Environment:

  • Set up export to your Applications Insights environment from the Power Platform admin center. Steps mentioned here.
  • Typically, one production environment or tenant maps to one Application Insights environment.
  • Post data export connection set up. Data will start being exported to your Application Insights environment, In the next 24 hours,.

Access the Application Insights Telemetry Data:

To access the Application Insights data

  • Connect to your Azure Portal.
  • Open the ‘Application Insights’ environment which you mapped to your Power Platform environment in the above section.
  • Under Monitor -> Logs, Run the Kusto queries.

Before jump on executing the queries, I highly recommend you to go through Telemetry-events-model-driven-apps and Telemetry-events-dataverse.

pageViews table
  • Application Insights page load data goes into the pageViews  table.
  • We need to query pageViews  table to fetch the Page load/User access related data.
  • Below is a sample query to pageViews table.

How to fetch the user access details.
  • To determine how the user is accessing the system, The userAgent attribute in the customDimensions field in the Application Insights pageViews table has this data.
  • Use the following query to get an overview of the different sources from where users are accessing the system:
| summarize count() by tostring(customDimensions.userAgent), user_Id

| where ['type'] == "UCI REQUEST"

Using the ‘Session ID’ to troubleshoot slowness or load issues:

  • Users can share their session ID from the About section of the App.
  • You can then use this ID to find issues by looking at all the activities in that session. Use the following query:
union *
| where session_Id == '[sessionIdHere]'


Azure DevOps | YAML | Could not load type ‘System.Management.Automation.PSSnapIn’

I got the following exception while executing a PowerShell script in my Azure DevOps pipeline step.

Import-Module : Could not load type 'System.Management.Automation.PSSnapIn' from assembly 'System.Management.Automation, Version=,


  • I used following ‘pwsh‘ task in my YAML file to execute the PowerShell script.
- pwsh: |
    <My Script>
    SYSTEM_ACCESSTOKEN: $(System.AccessToken)
  displayName: 'My Task'
  condition: succeeded()
  • For unversed, pwsh is the cross-platform edition of PowerShell built on .NET Core / .NET 5+; by contrast, powershell is the executable name of the legacy Windows PowerShell edition (v5.1-), built on the Windows-only .NET Framework (v4.8-).
  • The issue is ”System.Management.Automation’ is built on .Net Framework and ‘pwsh‘ can’t be used in this case.


  • Replace pwsh task with powershell task in YAML file.
- powershell: |
    <My Script>
    SYSTEM_ACCESSTOKEN: $(System.AccessToken)
  displayName: 'My Task'
  condition: succeeded()


Categories: DevOps Tags: ,

Power Platform | Managed Environments (preview)

As a Power Platform Admin its imperative to get your environment insights such as how many Apps in are not being used or how many Apps were shared with security groups or what are the implied DLP policies etc. So far there was no inbuilt feature in Power Platform to get the these insights.

If you are familiar with Center of Excellence (CoE) Kit you must be knowing on how to get insights of unused Apps and many other metrics. However Center of Excellence (CoE) Kit needs to be installed separately.

With Managed Environments (preview) feature this gap is being addressed in Power Platform.

Managed Environments

  • Managed Environment is a suite of capabilities that allows admins to manage Power Platform at scale with more control, less effort, and more insights.
  • Admins can enable Managed Environments on any type of environment (i.e., Default/Trial/Sandbox/PROD).

There are four primary elements of Managed Environments:

Enable Managed Environments:

  • Admins can enable Managed Environments using the Power Platform admin center or by using PowerShell.
  • To enable or Edit Managed Environment connect to Admin Center.
  • On the command bar, for an unmanaged environment, select Enable Managed Environments. For a managed environment, select Edit Managed Environments.
  • Configure Managed Environments settings and then select Enable.
  • Copy and restore environment lifecycle operations requires the Managed Environments property to be the same between source and destination.
  • Users with either the global admin, Power Platform service admin or Dynamics 365 admin Azure Active Directory roles are allowed to enable Managed Environments.
  • Users with the Delegated Admin role aren’t allowed to change the Managed Environments property in an environment.
  • Users with the Environment Admin (i.e., System Administrator) security role aren’t allowed to change the Managed Environments property in an environment.

Weekly Digests:

  • Once you opt for Weekly digest (i.e., Checking the ‘Include this environment’ checkbox) in the ‘Enable Managed Environments’ pane, Analytics about your top apps and flows, your most impactful makers, and inactive resources you can safely clean up are distilled and delivered to your mailbox once per week.

Sharing Limits:

Managed Environments allow admins to influence how broadly makers can share canvas apps. There are two sharing controls.

Sharing controlSystem behavior when checked?
Exclude sharing with security groupsMakers cannot share canvas apps with any security group.
Admins get the option to proceed with setting a limit on individuals shared to.
Limit total individuals who can be shared toMakers cannot share canvas apps with more individuals than specified in the text box.
  • Limit total individuals who can be shared to is only enabled if Exclude sharing with security groups is checked.
  • Sharing rules are enforced when makers attempt to share an app. Sharing rules do not change the audience apps in an environment that are already shared with.
  • Once sharing rules are set in the Power Platform admin center it may take up to 1 hour for the latest sharing rules to be propagated in the system and enforced.

Data Policies:

  • A principal capability of Managed Environments is enforcing Data loss prevention (DLP) policies.
  • New environment filters have been introduced to the data policies page in the Power Platform admin center that will help you identify all the data policies that are applied to an environment.
  • The environment filters are exclusively available for managed environments.
  • Open the Edit Managed Environments settings panel for a managed environment. In the Data policies section, select the See active data policies for this environment.
  • The data policies page opens in a new tab and displays only the data policies applied to the managed environment.

License considerations:

  • Managed Environments represents a value-add on top of existing premium Power Platform capabilities.
  • All low code assets (apps/flows) in a managed environment become premium and can be licensed using any of the Power Platform licensing options (per user, per app/flow or pay-as-you-go) or Dynamics 365 licenses that give premium usage rights.
  • Users must have a qualifying license to access the assets.
  • During the public preview the premium license requirement for applications and flows within a managed environment is not enforced.

Please refer the docs for more info.



PCF component import error | Publisher prefix for this control does not match the prefix for the solution

If you are New or Beginner in Power Apps component framework , I recommend you to refer PCF beginner article first.

Coming back to the blog post, other day while importing a solution with a PCF component, solution import failed with following error

Publisher prefix XXXX for this control XX.XXXX does not match the prefix XXX for the solution with Id xxxx-xxx-xxxxxxx-xxxxx-xxxxxx"


To understand the issue better, lets reproduce the issue by building a simple pcf control by following steps below:

  • Open Visual Studio Code and point to an empty folder.
  • Open a Terminal and execute following command to create a Control by name ‘Helloworld’.
 pac pcf init -n HelloWorld -ns sample -t field -npm true
  • Now build the control by running “npm run build” command.
  • Now that we have control in built state, let me push the control to my development Dataverse environment.
  • Execute “pac auth create –url https://myorg.crm.dynamics.com&#8221; to connect to Dataverse environment first.
  • Then, push the control to the connected environment using “pac pcf push –publisher-prefix sample command.
  • Above ‘pac pcf push‘ command creates a new unmanaged solution with naming convention “PowerAppsTools_{publisher_prefix}”.
    • In my case, a new solution “PowerAppsTools_sample” got created, as I mentioned the Publisher Prefix name as sample.
  • So far we could build a new PCF control and pushed to the Dataverse instance.
  • In my Development Dataverse environment, I already have a solution by name “MyCoreSolution” with Publisher ‘Rajeev’ having a prefix as ‘raj‘.
  • Now I want to include the PCF control which we just built to my “MyCoreSolution” solution and deploy to another environment.
  • So add the “HelloWorld” control to MyCoreSolution solution and export and save a zip file in your machine.
  • Open the new Environment and try importing “MyCoreSolution” solution, which we exported in previous step.
  • Import fails with following error
Solution "MyCoreSolution" failed to import: Import Solution Failed: CustomControls with Name sample.HelloWorld Import Solution Failed with following error: Publisher prefix sample for this control sample.HelloWorld does not match the prefix raj for the solution

Fix/Best Practice:

  • Hope you got an idea with above example on what’s wrong with solution import.
  • Because the PCF control prefix (i.e.,sample) is different than the “MyCoreSolution” solution’s Publisher prefix (i.e.,raj) we got the exception during import.
  • To avoid such issues, make sure your PCF control prefix matches with your Solution’s Publisher prefix, while importing the control to a different Dataverse environment.


Categories: PowerApps Tags: , ,

General availability of Power Apps for Windows

With “Power Apps for Windows”

  • You can find all your canvas and model-driven apps including your Dynamics 365 apps and use them online or offline just like you can on iOS and Android!
  • You can configure model-driven apps to work automatically offline by creating an offline profile. For canvas apps, you can use the LoadData/SaveData functions to create a seamless offline experience.
  • Get device capabilities like camera, microphone, file picker, barcode scanning, geo-location and many others.

This app has been optimized for great app performance and supports the latest advanced feature provided by the Power Platform like the native Dataverse connector, Guest access and AI Builder.

Installing the App

  • Go to the Microsoft Store and install Power Apps for Windows.
  • When the app is installed, open it and sign in.
  • All your canvas and model-driven apps including your Dynamics 365 apps will be shown up as below.

Refer official documentation for more details.


Categories: PowerApps Tags:

PCF | Using Fluent UI and React | Error during react installation

Other day while building PCF project using Microsoft Fluent UI and React, got an error while installing ‘React’ using following command.

npm install react react-dom @fluentui/react

Reason and Fix:

  • Reason was, React 18 was installed in my machine and Fluent UI will not install since it requires a React version less than 18.
  • To fix the issue run following commands which uninstalls the current version and installs Fluent compatible version of React.
npm uninstall react react-dom @fluentui/react
npm install react@16.8.6 react-dom@16.8.6 @fluentui/react@8.29.0

Please refer Scott Durow article on the same issue.


Categories: PowerApps Tags: , ,