Delegation in Canvas Apps

A couple of weeks ago I found an empty slot in my diary, and I (dangerously) thought “I know, I’ll brush up on my Canvas app skills!”.

In my role I find myself looking across multiple Dynamics 365 apps, Excel spreadsheets, and Power BI reports daily, and I set myself the task of bringing all of this together into one place so that I could access all of the data I need with one or two clicks instead of manually transforming data and keeping several browser tabs permanently open.

This was going great, until I saw the dreaded ‘delegation’ warning that all Canvas app novices will see very quickly in their career.

“Delegation warning. The Filter part of this formula might not work on large data sets.”

When you expand the warning, you get the following detail:

What is Delegation?

Simply put, delegation is an instruction from the target application to the data source, to carry out a query before returning the subset of results that are wanted by the target application itself.

This means that we only ever receive the desired data in the target application, and in turn, performance is increased as a result.

When you compare the processing required in this scenario compared to retrieving every piece of data and then filtering it in the target application, you see a measurable performance increase by using delegation, and you’re also increasing technical debt by pulling back data into the target environment that you want to throw away immediately.

Cause

The wording for this warning can be considered a little misleading. The warning is actually telling us that there will be a lack of delegation in the data source. In this instance, the data source does not have the ability to carry out the condition logic with its capabilities, and therefore it needs request that the Canvas app carries out the query instead.

For example, Power Fx provides the ability to retrieve a day, month, or year value from a Date field, but Dataverse cannot do this! Dataverse can only query date ranges such as ‘on or before [Date]’! When querying a ‘month’ in this scenario, you would receive the delegation warning as the delegation cannot happen.

As a result, the full data set from the data source has to be retrieved by the target application, only for the target application to filter the data once it has all been received. This lowers the performance of the app, but it could be worse than that – if you exceed the definition of ‘large data set’, the data set may not return at all, leaving you with incomplete results with no error and a low quality solution.

Solution

The biggest lesson learned whilst working on delegation recently was from a colleague – there is always a workaround.

Whilst you can’t “fix” the warning with the same piece of code, you can use combinations of delegated conditional logic in order to achieve the same results.

A classic example steps back into using dates in Canvas Apps. In Power Fx I can express “Month = 1”, but Dataverse only allows date ranges so the Canvas App needs to bring back the full data set to work out whether “Month = 1”. As a result, I can’t quite express “in January this year” using delegated logic, so instead I need to combine two ranges using something that Dataverse can recognise. In this example I would combine “Created On must be on or after 1st January 2021”, and “Created On must be on or before 31st January 2021” to obtain the right data at source.

Some examples can be more complicated than this, but a top tip for Dataverse specifically is that if you can achieve it using Advanced Find, then you can be certain that the logic can be delegated!

Have you worked in this space before and found any cool workarounds? Leave a comment below!

Tip: Quickly Enable Migrated Power Apps Portal Configuration

Microsoft’s documentation goes to great lengths in order to explain how we can migrate Power Apps Portal data from one environment to another by using the Configuration Migration Tool, but it doesn’t quite go as far as explaining how to re-point the already-provisioned portal to your newly migrated data upon first deployment.

Follow the below steps once you’ve moved your data in order to see your changes come to life!

1a. Locate via Dataverse

Navigate to Apps and find your Portal app from the list. Click on the three dots, and choose ‘Settings‘.

A screenshot of make.powerapps.com highlighting Apps and Administration.

Select the ‘Administration‘ option which will open a new tab.

1b. Locate via Power Platform Admin Centre

Navigate to the Resources tab which will expand to show a Portals option, and find your Portal app from the list.

A screenshot of the Power Platform admin centre, highlighting the Portal and Manage options.

Click on the three dots, and choose ‘Manage‘.

2. Update Portal Bindings

A screenshot of the Power Apps portals admin centre, showing the Update Portal Binding option.

Stay on the ‘Portal Details‘ tab and scroll down to ‘Update Portal Binding‘ and choose the newly migrated Website Record from the list.

What is Microsoft Power Platform?

Do you keep hearing about the Power Platform but don’t really know what it is? Well let me tell you everything you need to know in this short video!

In my role at QUANTIQ as the Power Platform Team Manager, I had the opportunity to join in with the video-first campaign where a number of us provide you with an overview of the Microsoft Cloud products we offer consultancy and services for. You can find the rest of the videos available here, and if you want to find out more, please do get in touch!

P.S – Hearing an excited 4 year old shout “Daddy is on YouTube!!” was definitely the highlight of this campaign for me, there’s nothing like it!

What is Microsoft’s Accessibility Insights for Web?

One of my favourite things about consulting in Power Apps Portals is that I am able to step back in to the world of traditional web development temporarily, and I get to explore a whole host of tools to improve our solution.

Visual improvement tools are cool, but helping ourselves reach a wider audience whilst simultaneously improving inclusivity is even better! This is where Microsoft’s Accessibility Insights for Web tool comes in to play.

The tool can be used for any website, but in this blog post I’ll use a Power Apps Portal as an example.

Context

Accessibility in digital services is all about providing alternative navigational aids and component references for those with impairments, and they can be elements that could be visible or hidden to all users. A couple of examples include:

  • Ensuring that the colour contrast between background colour and text that sits on top is significant enough to be considered easily readable. Using two similar colours may create difficulties for those with colour blindness.
  • Defining Tab Indexes in the website’s code to explain the order of your site’s navigation, so that anyone using a screen reader can access the components (such as a navigation bar with child links) in a logical order.

Regulations came into force in the late 2010s in many parts of the world, and more specifically, in the UK all public sector organisations had to ensure that their website was considered accessible by 23rd September 2018. If this isn’t possible, the organisation needs to provide a suitable alternative.

As many of the largest suppliers of digital services now give you the ability to create your own content, whether that’s social media or the Power Platform, many of the tech giants have created tools to empower you to make your content accessible, as it would be impossible for the tech giants themselves to automatically make every single piece of digital content meet these standards.

Getting Results Quickly Using FastPass

To get started, you don’t need a Microsoft account or even need a log in for your website. This tool can be run against any website to measure the closeness to common accessibility standards, or lack of. The tool is installed as a browser extension and is available for most modern browsers here.

To run the tool, simply click the following icon within your browser’s navigation bar:

Accessibility Insights for Web icon that is visible in your browser's navigation bar. A blue heart with a white search icon.

The browser window will give you several options which are self-explanatory, but to get reasonable results fast, the ‘FastPass’ option works well enough straight away.

A notification will pop up alongside the report for automated checks which instantly gives you a visual summary of all of the issues that have been raised.

A screenshot of a web browser showing the Accessibility for Insights Web tool by Microsoft with two different errors.
This particular portal has two errors relating to HTML code.

And there you have it! Within a few minutes you now have a list of potential issues to resolve shown in Step 1, and if you’re unfamiliar with the specific results you receive, there is plenty of information from the report or the web.

A screenshot of the FastPass results, showing two issues on the homepage of the demo website, with visual indicators on the website itself.

If you keep the report open on this page, as you expand your selection in the report, it will highlight on your original web page exactly where the issue is found and it will explain how to fix in order to avoid lengthy researching or development processes for someone that is comfortable editing HTML.

Moving on to Step 2, this provides a way to understand how accessibility tools will behave on our website when using ‘Tab Stops’ to navigate the screen.

A screenshot of the tab index being recorded by the report on my demo website to tell us how a screen reader will navigate the website.
Tab Stops are flowing in a logical order on this website, moving from left to right before shifting down to the next interactive item on the page.

To enable this, you simply press the ‘tab’ key on your website linked to the report and indicators will display for all elements on the page that are included within the ‘Tab Index’, and as this is subjective, the user is expected to decide whether the current order is correct.

Full Assessment

Whilst FastPass is likely to be beneficial for most small websites, for larger audiences or those in the public sector, you may want to consider running a full automated assessment. This is the second option available from your browser’s extension, and returns a significantly larger set of results in trade-off for a slower running time.

A screenshot of the full Assessment feature being run against a website looking at every component for accessibility issues.
Full assessment being run on a website.

Once the report has been completed, you can navigate to any items on the left-hand side of the browser window, focussing on those with an X to identify where issues lie, and once opened, the conventions used for displaying issues and recommendations follows the same path as the FastPass option.

Final Thoughts

Just because accessibility regulations aren’t law for all websites, it doesn’t mean that we shouldn’t consider this within our digital assets. For someone that is comfortable with HTML, running the tool (remember, it’s free!) with the FastPass report and fixing two issues could take less than one hour to change your homepage, but it could open up your site’s usability to a whole host of new audience members, not only increasing reach, but improving the perception of your services or product for those that need accessibility features everywhere.

When you’re next on social media or working with a website that you or your organisation owns, take a look at the accessibility features and you might open up a world of seemingly hidden features to make the digital experience better for all!

Microsoft’s Accessibility Insights for Web

Useful Guidance & Tools for Digital Accessibility

Colour Hex

Expect Dataverse Deployments To Fail First Time

Whilst the process of deployment hasn’t changed too much since the days of Dynamics CRM, one thing that has changed significantly is the volume of possible components that can be included in a solution file.

Not only is this due to an increase of readily-available functionality from Microsoft, but also by the ability for end users to install their own components, which in turn creates more dependencies on (what we think) is our small solution of configuration changes to be deployed from one environment to another. This can increase the number of failures that can occur during delivery, and often, the end user error isn’t very helpful.

A generic error provided by the Power Platform when trying to deploy a solution.

Solution deployment failures don’t have to be a problem, in fact, we should expect them.

In this blog post I will help you understand how to troubleshoot a failed deployment so that you can solve the issue in an informed way.

Step 1: Download A Code Editor

We want to ensure that the output from the failure is in a readable format, and for this we need a code editor that recognises XML formatted files. My preference as a functional consultant who needs to open the occasional file is Notepad++. It’s free, and it has an XML Tools plugin which allows you to ‘pretty format’ any XML files. You can also use Visual Studio or Visual Studio Code – I suspect some of you reading this will already have one of these installed!

Step 2: Download The Solution’s Log File

Whenever someone approaches me with a failed deployment, the first thing I ask them for is the log file. When you open this file in Notepad++, use ctrl+alt+shift+B, which will ‘pretty format’ your XML file. It’ll look something like this:

A screenshot of Notepad++ with XML Tools plugin installed. The file shown here is using 'pretty format' to make the code readable.

It looks difficult to decipher to the untrained eye, but we can quickly start to understand why the solution is failing with a few tips when we break down the file.

Step 3: Understand The Dependency

Let’s take a look at the first dependency, defined by the <MissingDependency> XML tags.

A snippet of code showing a missing dependency.

You’ll notice a <Required> line and a <Dependent> line which both include a Type. This, alongside the schema name, is the most important part of the dependency, as the two combined tell us what we’re looking for.

Fortunately we don’t need to remember all of the types as Microsoft provide a handy reference guide here.

We simply need to cross-reference the numbers in our dependency, and we now know that to complete the deployment we need to include the “Offering” entity (table) for the “Service” System Form.

Step 4: Modify Your Solution

We have two choices here:

  1. Remove the Service System Form from the solution, or,
  2. Add the Offering entity (table) into the solution.

In this particular instance it would make more sense to add the Offering into the solution, but sometimes you may challenge whether the component is really needed within your deployable solution, in which case, you’d remove the System Form.

Step 5: Rinse & Repeat

Not all dependencies will be resolved within one solution modification, but that’s ok, and you may need to repeat steps 3 & 4 multiple times before you have a solution file that can be successfully deployed. The key is to remember that failures can be expected, and that they don’t always have to be a problem!