In working with authenticated web applications, we've come to understand that the word delegation typically refers to delegating tasks to a different user, or, logging in to an app as one user but acting on behalf of another user (assuming the logged in user has permissions to do so). 

PowerApps puts a new spin on delegation by using it to describe the ability of Gallery/DataSet controls to load records as you scroll(we're 'delegating' the query heavy lifting to the server instead of having it on the client).  This is a great feature because you can completely avoid the usage of paging controls that have been a staple of XRM applications for as long as I can remember.

As with any powerful feature, we as developers have the responsibility to ensure that it performs adequately even with large datasets and other conditions added to the Gallery/DataSet. 

Its important to note, that not every Connector and Function can be delegated.  If the dataset cannot be delegated, there is a static number of records that will be retrieved, without the option to use paging.  The default max number of records is 500 and can be adjusted from 1-2000.  If Filters are added to the dataset, the filters will be applied after the 500 records are returned, so a query with filters that should return 500 will likely return fewer than this.  It's not always obvious when testing/developing, if delegation is working or not, so a good practice that will help catch issues with it is to set the max records returned to 1, instead of the default of 500. 

The connectors that can be delegated are:

  • Common Data Service
  • SharePoint
  • SQL Server

The functions that can be delegated are:

  • Filter()
  • Search()
  • LookUp()

Using functions on columns outside of the list above will result in either:

  • A warning message stating the formula may not work well on larger datasets

  • In this case, delegation may still work, testing is necessary to determine if its viable to use on your dataset
  • Delegation not working and resulting in the  Data row limit for non-delegable queries being enforced (i.e. the first 500 rows will be returned and no paging is possible)

Certain Aggregate Functions will also try to take advantage of delegation, outside of a Gallery or Data Table control. 

CountRows, Average, will be constrained to the limit for non- delegable queries, for instance:

In conclusion,

Delegation is a powerful feature that will allow you to show large datasets without sacrificing loading time.   With this power, comes the responsibility to ensure that the functions used to display the dataset will not disable delegation.  To quickly ensure that delegation is working, set the data row limit for non-delegable queries to 1 unless you need to use non-delegable queries.