Delegation in canvas apps power apps. know about it before you start working with large datasets.

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

Canvas apps is certainly changing a customer’s view point on mobile rollout feasibility for their business. However more often than not, we as consultants come across customers having significant data in the system. And while we don’t think much about data volumes while dealing with model driven apps, the same cannot be said about canvas apps.

And why is that so? The reason is because of “Delegation”. A very detailed explanation of the delegation feature is explained in this docs link. However let’s see from the implementation perspective how does it affect the canvas app you build.

Advertisements

So the first question is – “What is delegation?”. Usually when we hear the term delegation, we think of something related to user access like delegate privileges and stuff. But delegation in canvas app is related to fetching of data from data sources.

Well canvas app have some really formulas built in to query and filter data sources, very much excel like. So what happens when you put a query similar to the one below in Canvas apps.

image

If you track the request in Fiddler, this is what you get

Advertisements

/api/data/v9.0/accounts?$filter=(name eq ‘Test’)&$select=accountid,name

As you can see canvas app delegates the query to data source and gets the results back. Kind of obvious right? After all if there are thousands of records in the system it would be extremely bad design to bring in all the records to client and then apply the filter.

But there are some situations where canvas apps need to do just that. And why is that so? As I have mentioned earlier since canvas apps supports excel like formula, not all filters can be applied directly to data source as that might not be supported. Let’s take an example where I want to show the average of the credit limit for all my accounts. Below is the formula for the same.

image

The moment I write this formula, I get a blue line below it and then get a delegation warning that it might not work correctly on large data sets. The reason is the formula cannot be delegate to data source.

Advertisements

Now the question arises – “Does Canvas app bring all the records on the client side and try to take the average?”. Well the answer is No. For performance benefit, canvas app will bring in only the first 500 records no matter how much data you have in the table. Even the 501th record would not be considered for average calculation in my query. Hence the average value may not reflect the correct value.

Trust me this have happened so many times with me where I received the complaint that data shown is not being correct.

Advertisements

Is this 500 limit set somewhere or is it hardcoded in the framework? Well it’s configurable till a maximum value of 2000.

To change this limit, go to File menu of your canvas app and then Settings –> Advanced settings –> Data row limit for non-delegable queries

image

So keep in mind this delegation stuff next time you query with large data sets.

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s