Archive

Archive for the ‘PowerApps’ Category

Canvas App | Display and Download large data sets of Images from Azure Blob Container with no delegation issues

In one of my previous articles, I detailed the steps to embed a Canvas app with upload image to Azure Blob feature.

In this article lets see, how to work with large data sets and achieve following:

  • Displaying blob images in Gallery.
  • Ability to Download the image.
Pre-requisites:
  • Azure Storage Account and Container. Get free Azure subscription here
  • Dynamics 365 account. Get 30 days trail here

Set up Azure Storage Account and Container

  • Connect to your Azure portal.
  • Create a new Storage Account and capture the Storage Account ‘Name’ and ‘Access Key’.
    • I’ve named Storage Account name as ‘expmar’
  • Create a new Container and copy the Name.
    • I named my Container as ’employee’.
  • Upload few images, which will be used to display in Canvas App.

Steps to create Canvas App and Connect to Azure Blob

Create Azure Blob Storage Connection:
  • Connect to Power Apps Portal using your Dynamics 365 account.
  • To connect to Azure Storage Account from Canvas App, we need a new ‘Azure Blob Storage’ Connection.
  • Click on ‘Data -> Connections -> Azure Blob Storage’ and provide Azure Storage Account ‘Name’ and ‘Access Key’ captured in previous section and click ‘Create’.
  • Up on successful creation, you should see the ‘Azure Blob Storage’ under ‘Connections’.
Steps to Create Canvas App and display blob images
  • Create a new Canvas App.
  • Add the ‘Azure Blob Storage’ connection created in previous step to the Canvas App from ‘Data -> Add a connection’.
  • As we established connection to Azure Storage Account, next, connect to ‘Container’ (i.e., Employee) and read the images to a List.
  • Use following formula on App’s ‘On Start’ event.
  • This formula, reads the images from ’employee’ Container and store the images in ’employeePhotos’ Collection.
  • Now we have the images in ’employeePhotos’ Collection, add a Gallery control and bind to ’employeePhotos’ Collection.
  • To display images, In the Gallery, add an ‘Image’ control and in the ‘Image’ property add following formula.
  • To display image name, add a ‘Label’ control and set Text as ‘ThisItem.DisplayName’.
  • To check whether images are rendering click on ‘App -> Run OnStart’ and you should see the images upload to Azure Blob Container in the Gallery.

Steps to Build Download feature
  • To download an image from Azure Container, we would need following 2 values:
    • URL : Azure Storage Account URL.
      • URL format would be “https://{Storage Account Name}.blob.core.windows.net
      • In my case, its “https://expmar.blob.core.windows.net”
    • SasToken (Shared access signature Token):
      • Generate the ‘Shared access signature’ as below from Azure portal.
  • Set ‘URL’ to ‘bloburl’ and ‘Token’ to ‘sastoken’ variables ‘OnStart’ of the App.
  • Complete ‘OnStart’ formula looks as below.
  • Add a ‘Download’ icon to the Gallery.
  • On ‘OnSelect’, use ‘Download(bloburl & ThisItem.Path & sastoken)’ formula.

Test the App
  • Run the App and you should see Images and ‘Download’ icon as below.
  • Click on ‘Download’ icon and image should get downloaded.

🙂

Categories: PowerApps Tags: , ,

Canvas App Import Failure | CanvasAppEnvironmentMismatch error

February 9, 2021 Leave a comment

We configured a new Dynamics Instance copied from another Instance using ‘Customizations and schema only’ option.

While importing a solution with a Canvas App, the solution import failed with CanvasAppEnvironmentMismatch error

CanvasApp import: FAILURE: Code: CanvasAppEnvironmentMismatch Message: The specified app ‘xxx-xx-xxxx-xx’ belongs to the environment ‘xxx-xx-xxxx-xx’ and not ‘xxx-xx-xxxx-xx’ which is the environment associated to instance ‘xxx-xx-xxxx-xx’

Its a strange because, the Instance is a copied one and there were no Canvas Apps exist, when checked in the PowerApps Portal -> Apps tab.

Reason:

  • Even though the PowerApps portal not showing up any Apps, when queried the ‘Canvasapps’ Data Verse entity using oData URL, there were Canvas App records pointing to a different Instance (i.e., The Source Instance which the current instance copied from).
    • Copy the name of the App from json collection. We would need it in next steps.
  • Solution import failed because of the matching Canvas App entry pointing to a different Instance in ‘Canvasapps’ entity.

Fix:

  • Write a C# console and delete the entry in ‘Canvasapps’ entity.
  • Following is the sample code.
 var queryCanvasApps = new QueryExpression("canvasapp")
                {
                    ColumnSet = new ColumnSet(true)
                };

                var filter = new FilterExpression(LogicalOperator.And);
                var cond1 = new ConditionExpression("name", ConditionOperator.Equal, "{App_Name copied in above section}");

                filter.Conditions.Add(cond1);
                queryCanvasApps.Criteria = filter;

                var apps = CrmService.RetrieveMultiple(queryCanvasApps);

                foreach (var app in apps.Entities)
                {
                    //Delete the App entry
                    CrmService.Delete("canvasapp", app.Id);
                }
  • Post deletion, reimport the solution and it should work.

🙂

‘Callback Registration Expander’ System Jobs stuck at ‘Waiting For Resources’

January 30, 2021 1 comment

We set up a new Dynamics Instance by copying from another Instance using ‘Copy environment’ option from Power Platform Admin Center.

We opted ‘Copy over’ as ‘Customization and schema only’, as we don’t need the data to be copied over to the Target instance.

On the Target instance we’ve started the Data Migration activity and noticed frequent connection timeouts. When checked the ‘System Jobs’, there were many “Callback Registration Expander” Jobs stuck at “Waiting For Resources” state.

Reason:

  • To understand “Callback Registration Expander” jobs , lets first understand Callbackregistration entity.
  • ‘Callback Registration’ entity stores the configuration of Processes and Cloud flows (i.e., Power automate flows).
  • So, if you create a new Flow on the instance, a new entry goes in to ‘Callback Registration’ entity.
  • Coming back to our issue, when we configured the new Instance using Copy option, “Callback Registration Expander” jobs from the source instance copied to new instance.
  • Since the “Callback Registration Expander” jobs looking for records from Source instance, which are unavailable in Target, jobs stuck at “Waiting For Resources” state.

Fix:

  • Its a product issue.
  • To fix the issue, We had to delete the ‘Callback Registration’ records from new instance.
  • Create a flow or write a C# console to delete the ‘Callback Registration’ records.
  • This deletion step, deletes the entries carried over from Source instance.
  • Now, disable and enable flows in new Instance which create new entries in ‘Callback Registration’ records.

🙂

[Step by Step] Debug Model Driven and Canvas Apps using ‘Monitor’ tool

January 26, 2021 Leave a comment

Monitor tool overview

Using Monitor tool,

  • Makers of canvas apps can view events while building a new app or to monitor published apps.
  • Makers of model-driven apps can monitor page navigation, command executions, form-related issues, and other major actions.

Using Monitor with Model Driven App

Lets see step by step to use Monitor with Model Driven App.

  • Connect to Power Apps Portal.
  • Select the Model Driven App from either from ‘Apps’ tab or from ‘Solutions’ and select the ‘Monitor’ option from Command bar.
  • A new Monitor session opens up as below in a browser tab.
  • Click on ‘Play model-driven app’ to start the diagnosis.
  • After the app is opened from Monitor, you’ll see a Join monitor debug session? dialog box. Select Join.
  • A notification shows up to denote monitor is in progress.
  • While you navigate through the Model driven app, events begin to flow to the Monitor session screen.
  • You can also ‘Invite’ other to monitor the session.
Events monitored

Following are few events we can track in Monitor tool.

  • FullLoad : Signifies the complete load of a page navigation, such as an edit form load. This event waits for certain network requests to complete and all rendering to finish, so the form can be ready before FullLoad completes.
  • Network : Reveal details about each request made from the app.
  • Page navigation, command executions, form saves, and other major actions will send key performance indicators and network events to Monitor.
  • Script errors: Monitor receives events from the app with more details about the script errors, so you can debug more quickly, and easily.

Using Monitor with Canvas App

Using Monitor, we can trace events as they occur in a canvas app during the build, or we can use Monitor to debug the published version of a canvas app.

Monitor Canvas app during the build
  • Open the Canvas app using ‘Edit’ option.
  • From the ‘Advanced Tools’, select Monitor -> Open monitor.
  • A new browser tab opens Monitor screen and connects it to your existing Power Apps Studio session. A notification appears as “Studio Session”, which denotes its Canvas app during build.
  • Run the ‘Canvas’ app and you would see the events logged as below.
Monitor Published Canvas app
  • Select the App and select ‘Monitor’ Or, you can select More Commands (), and then select Monitor.
  • A new browser tab opens Monitor screen. Click on ‘Play published app’.
  • This action opens the published app in a new browser tab and connects it to your current Monitor session.
  • You would notice a banner and record kind of icon at the top.
  • To view the source expressions in Monitor for the published app, you need to turn on the setting to publish the expressions with the app. 

Notes:

  • You can run a model-driven app and add “&monitor=true” to the end of the URL in the browser. Then, select Monitor on the command bar to start a monitoring session in a new tab.

🙂

Canvas App | Dataverse | Distribute columns to multiple forms and Patch

January 18, 2021 Leave a comment

When working with large tables in Canvas App’s Phone layout Forms, it would be counterintuitive to place all the fields in a single form. In below screen, user has to scroll a lot to fill all the details.

In this article, lets see how we can simplify above screen by distributing fields in multiple forms and finally use the Patch function to save the information in to Dataverse from all the forms.

I am taking the OOB ‘Contact’ table in this scenario and distributing fields in to 3 screens (i.e., Basic Details, Contact Details and Additional Details). Lets get started.

  • Create a new Canvas App from Maker portal.
  • From the ‘Data’ tab, Select ‘Entities -> Current environment -> Contacts’ table and add to the App.
  • Add 3 screens (Basic Details, Contact Details and Additional Details) to distribute fields.
  • In the Basic Details screen (i.e., scrBasicDetails), add a new Form (i.e.,formBasicInfo) and add following fields from ‘Contact’ Datasource.
  • Add a Button, to navigate to next screen (i.e., scrContactDetails). Add following formula on ‘OnSelect’ of button.
  • Similarly, In the Contact Details screen (i.e., scrContactDetails) add a new Form (i.e.,formContactDetails) and add following fields from ‘Contact’ Datasource.
  • Add a Button, to navigate to next screen (i.e., scrAddlDetails) by triggering ‘Navigate’ function on ‘OnSelect’ of button.
  • In the last ‘Additional Details’ (i.e., scrAddlDetails) screen, add a new Form (i.e.,formAddlDetails) and add ‘Attachments’ field to capture and store documents to Dataverse.
  • Since this is our final screen, Add a Button to Submit the data to Contact table in Dataverse using following ‘Patch’ function.
  • Post submit refresh the forms using NewForm() function.
  • Display a banner message using ‘Notify’ function.
  • Finally Navigate back to first screen (i.e., scrBasicDetails) using Navigate() function.
  • Combined formula is as below.
// Patch : Use Patch with the Defaults function to create records.
// form.Updates : Gets the data from the fields presented on the from.
Patch(
    Contacts,
    Defaults(Contacts),
    formBasicInfo.Updates,
    formContactDetails.Updates,
    formAddlDetails.Updates
);
// NewForm : Sets the form mode to Insert so that you can submit a new Contact.
NewForm(formBasicInfo);
NewForm(formContactDetails);
NewForm(formAddlDetails);
// Notify : Display notification
Notify(
    "Contact submitted successfully",
    NotificationType.Success
);
// Navigate : Navigates to first screen
Navigate(scrBasicDetails);
  • Run the App, provide details and navigate to next screen and upload images and finally click ‘Submit’ to save data to Dataverse.
Combined screenshot of 3 forms
  • Now go to Dataverse using Model Driven App and open the Contact -> Audit History, to prove only one transaction triggered with our Patch function.

🙂

Categories: PowerApps Tags: , , ,

[Step by Step] Canvas App | Dataverse | Filter, Patch, For All, Lookup

January 3, 2021 2 comments

In this article, lets understand the Filter, Patch, For All and more functions and formulas using following ‘Car and Customer’ scenario. I will be using Dataverse formerly CDS as Data Source.

  • Create a ‘Manufacturer’ table to store Car manufactures.
  • Use OOB ‘Contact’ table to store Customers.
  • Create a ‘Cars’ table to store Cars.
    • Configure ‘Contact’ and ‘Manufacturer’ look ups in ‘Cars’ table.

Lets proceed first by understanding ‘Data Model’ and then with creating ‘Canvas’ App.

Dataverse Data Model:

  • ‘Cars’ form with ‘Manufacturer’ and ‘Customers’ look up.
  • ‘Cars’ view.

Configuring Canvas App

Lets build the Canvas App, with following features:

  • Add “Manufacturers”, “Cars” and “Contact” (i.e., Customer) Data Sources.
  • Add ‘combManufacture’ Combo box to show ‘Active’ Manufacturers.
    • Select ‘Data source’ as ‘Manufacturers’.
    • Select ‘Active Manufacturers’ from the ‘Views’.
  • Add ‘combCustomers‘ Combo box to show ‘Active’ Customers (i.e., Contacts).
    • Select ‘Data source’ as ‘Contacts’.
    • Select ‘Active Contacts’ from the ‘Views’.
  • Filter the ‘Cars’ by selected ‘Manufacturer’ and set to ‘collCars’ collection variable.
    • Formula : ClearCollect(collCars,Filter(Cars,Manufacturer.Manufacturer=combManufacture.Selected.Manufacturer));
  • Add ‘galCars’ Gallery control and select the ‘Data Source’ as the collection variable from previous step.
  • In the Gallery, add a ‘Checkbox’ control to enable selection and a Label to show the ‘Customer’.
  • On check of ‘Checkbox’ add the selected ‘Car’ to ‘selCars’ collection variable, using ‘OnCheck’ event.
    • Formula : Collect(selCars, ThisItem);
  • On uncheck of ‘Checkbox’ remove the selected ‘Car’ from ‘selCars’ collection variable, using ‘OnUncheck’ event.
    • Formula: Remove(selCars, ThisItem);
  • Add ‘Set Owner’ button to map the selected Cars and Customer.
    • First move the selected ‘Cars’ from ‘selCars’ collection to ‘tempCollection‘ by renaming ‘Primary’ column to “ID” using RenameColumns function.
    • Use ForAll function to loop through ‘tempCollection‘ (i.e., Selected Cars) and update the ‘Contact’ lookup with ‘combCustomers‘ selected record using Patch function.
    • Reset the Cars Gallery(i.e., Reset(galCars)) to refresh.
    • Display the message using Notify function.
    • Clear the collection variables.
    • Formula: ClearCollect(tempCollection,RenameColumns(selCars,”crbb8_carid”,”ID”));ForAll(tempCollection,Patch(Cars,LookUp(Cars,Car=ID),{Contact:combCustomers.Selected}));Reset(galCars);Notify(“Update Successful..”,NotificationType.Success);Clear(tempCollection);Clear(selCars);
  • Add ‘Clear Owner’ button to unmap the selected Cars and Customer.
    • To unmap the Customer with Car, clear ‘Contact’ look up by setting ‘Blank()’ function (i.e., {Contact:Blank()}).
    • Use ‘For All’ and ‘Patch’ functions as above to update the record.
    • Formula : ClearCollect(tempCollection,RenameColumns(selCars,”crbb8_carid”,”ID”));ForAll(tempCollection,Patch(Cars,LookUp(Cars,Car=ID),{Contact:Blank()}));Reset(galCars);Notify(“Update Successful..”,NotificationType.Success);
  • Now run the App and you should see screen as below.

Refer this article for PowerApps functions and formulas.

🙂

Categories: PowerApps Tags: , ,

Power Apps | Unable to query Canvas App using CDS WebAPI

September 27, 2020 Leave a comment

In my Power Apps Environment I have the following ‘Hello World’ Canvas App.

When I query ‘Canvas App’ entity using Web API from same Environment, there were no Canvas App records returned.

Reason:

  • If you create a Canvas App from ‘Apps’ tab outside of solutions or imported any App to the Environment, Canvas App will not be available in CDS until its added to a solution.
  • Open any of the unmanaged solution from the Environment, use ‘Add Existing’ and select the ‘Hello World’ Canvas App from ‘Outside solutions’ tab.
  • Once added a ‘Name’ gets populated and looks as below.
  • Now query the ‘Canvas App’ entity using Web API and now we should get the ‘Hello World’ Canvas App record.

🙂

Categories: PowerApps Tags: ,

Power Platform Admin Analytics

September 27, 2020 Leave a comment

In previous Dynamics versions, with the help of Organization Insights, available as a preferred solution from AppSource, we can get the organization level insights such as No of Active Users, API Calls, etc.

Now  these analytics can be viewed right from the Power Platform Admin Center with no need of additional solutions.

Currently there are 3 types of Analytics are available.

Who can view the Analytics reports:

Admins with the following roles and a license can view the analytics:

  • Environment Admin – can view reports for the environments that the admin has access to.
  • Power Platform admin – can view reports for all environments.
  • Dynamics 365 admin – can view reports for all environments.
  • Microsoft 365 Global admin – can view reports for all environments.

Refer this article for more details

🙂

Categories: CRM, PowerApps Tags: ,

Microsoft Teams and PowerApps – Project Oakdale

September 24, 2020 1 comment

Project Oakdale, a new built-in low-code data platform for Teams that provides enterprise relational datastores with rich data types to Teams users, is now in public preview.

Solutions built with Power Platform can be easily published to the Teams app store and can be used off the shelf or customized for specific needs.

Lets see how to embed a Power app in Teams.

  • Connect to Office 365 portal and check if you have ‘Teams’ enabled.
  • If no Teams available, go to Teams site and sign in with Office 365 credentials.
  • Go to Teams and click on Apps->Power Apps and click ‘Add’.
  • A ‘Power Apps’ tab adds to the Teams.
  • From ‘Power Apps’ , either create a new App by clicking ‘Create an app’ or pick any of the readily available apps.
  • Once you choose existing App, select a Team’s Channel where this App needs to be available. I chose ‘Hello World’ team’s ‘General’ channel.
  • App takes few minutes to complete the setup.
  • Grant the required permissions.
  • App loads as below and ready to be used.

Notes:

  • Project Oakdale environments are automatically created for the selected team when you create a Power app in Teams for the first time or install a Power Apps app from the app catalog. See About the Project Oakdale environment.

🙂

Categories: PowerApps Tags: ,

Power Apps | Custom connector | User does not have an entitlement to use PowerApps

September 2, 2020 Leave a comment

From the Dynamics trial instance, while registering a Custom Connector, encountered following issue.

Reason:

  • Error message states clearly, that the User who is trying to register ‘Custom Connector’ does not have ‘Power Apps’ license.
  • By default when you subscribe for trial , Dynamics only grants the ‘Dynamics 365 Customer Engagement Applications’ license which does not have ‘Power Apps’ option.
  • To check the User license, connect to Microsoft 365 Admin Center
  • Go to user’s ‘Manage product licenses’ tab.

Fix:

  • Grant the user Power Apps license to the user.
  • One option is by subscribing for the ‘Dynamics 365 Customer Engagement Plan‘ license by following below steps.
  • Connect to Microsoft 365 Admin Center
  • Go to ‘Billing -> Purchasing Services’.
  • Select ‘Dynamics 365 Customer Engagement Plan Trial’ and click on ‘Get free trial’.
  • You would get following confirmation page up on procurement.
  • Now open the User, and grant the ‘Dynamics 365 Customer Engagement Plan’ license.
    • Make sure ‘PowerApps for Dynamics 365’ is enabled.
  • You should be able to configure Custom Connector now.
  • Refer Power Apps license guide for more details.

🙂

Categories: PowerApps Tags: ,