cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
James_Hellfeier
Level: Powered On

Sharepoint Delegation

I've been having some trouble with PowerApps throwing me delegation warnings when working with a Sharepoint list.

 

Here is the code I'm using to pull in Sharepoint list data in "chunks" of 500 at a time.

 

- 'eRad Cases' - Sharepoint List I am pulling data from

- miniID : calculated Numeric sharepoint field that is an auto-incremented integer (NOT the original ID that is assigned to each record)

- colMiniCaseList : collection generated from the Sharepoint list

 

UpdateContext({ctxMinRecID:First(SortByColumns('eRad Cases',"miniID",Ascending)).miniID});
UpdateContext({ctxMaxRecID:First(SortByColumns('eRad Cases',"miniID",Descending)).miniID});
UpdateContext({ctxNumberofPasses:RoundUp((ctxMaxRecID-ctxMinRecID)/500,0)});
ClearCollect(colNumbersTable,Filter('[dbo].[NumbersTest]',Number<=ctxNumberofPasses));
ForAll(colNumbersTable,Collect(colMiniCaseList,Filter('eRad Cases',miniID>=ctxMinRecID+((Number-1)*500) && miniID<ctxMinRecID+(Number*500)))

- ctxMinRecID : minimum record ID grabbed from Sharepoint list

- ctxMaxRecID : maximum record ID grabbed from Sharepoint list

- ctxNumberofPasses : determines how many "chunks" of 500 I need in order to download the entire list

- '[dbo].[NumbersTest]' : used to generated colNumbersTable ... simply used as an ordered list in order to record how many records need to be pulled

 

 

My issue is that somewhere in my code, PowerApps doesn't think that the Sharepoint list is delegable, which I feel stems from the First() function. I previously had this set up with a SQL database and PowerApps has no issue delegating the First(SortByColumns( '[dbo]' )), given the SortByColumns() already delegated through the SQL database and First() was just grabbing the first value in the list ... thus no flags were thrown (and data was fully retrieved.)

 

So, should Powerapps have been throwing me a flag when delegating this on a SQL database, or should the flag be ignored when delegating this on a Sharepoint list?

 

 

EDIT : It has to do with the ( + ) .... should have combed the documentation a bit better ...

 

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Sharepoint Delegation

Hi @James_Hellfeier,

I have a couple recommendations here. 

First, I would put in the range to compare against inside colNumbersTable itself. Big idea: If you can relocate your calculation into a collection ahead of time, you'll gain back performance when filtering against it later.

 

Ex. 

If the first id is #1234, then

Loop 1 would retrieve rows 1234-1735

Loop 2 would retrieve rows 1734-2235

 

This can be done by adding columns to colNumbersTable 

ClearCollect(colNumbersTable,
    AddColumns(
        Filter('[dbo].[NumbersTest]',Number<=ctxNumberofPasses),
    "min",ctxMinRecID+((Number-1)*500),
    "max",ctxMinRecID+(Number*500)
    )
)

This means, "Create a collection of numbers that will be used for telling PowerApps how many times to get 500 records at a time. For each n, pre-determine what minimum to maximum range of id numbers would be."

 

Then you would revise your collection of records to reference the min and max.

Clear(colMiniCaseList);

ForAll(colNumbersTable,
    Collect(colMiniCaseList,
        Filter('eRad Cases',
            miniID>=min,
            miniID<max
        )
    )
)

While this scenario is possible, I am curious why you are using a combination of SharePoint and SQL in this way. If you migrate your data to SQL which you already have, you can create SQL Views to aggregate your data in commonly used views. 

https://powerapps.microsoft.com/en-us/blog/using-sql-server-views-in-powerapps/

 

You'll find that when you bring in tens or hundreds of thousands of records into your app, it will take a performance hit. This is why even first party apps page their data.

View solution in original post

3 REPLIES 3
Administrator
Administrator

Re: Sharepoint Delegation

adding in @Chris to assist 

 

@TopShelf-MSFT

Super User
Super User

Re: Sharepoint Delegation

Hey @TopShelf-MSFT this sounds like a job for @mr-dang

PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Sharepoint Delegation

Hi @James_Hellfeier,

I have a couple recommendations here. 

First, I would put in the range to compare against inside colNumbersTable itself. Big idea: If you can relocate your calculation into a collection ahead of time, you'll gain back performance when filtering against it later.

 

Ex. 

If the first id is #1234, then

Loop 1 would retrieve rows 1234-1735

Loop 2 would retrieve rows 1734-2235

 

This can be done by adding columns to colNumbersTable 

ClearCollect(colNumbersTable,
    AddColumns(
        Filter('[dbo].[NumbersTest]',Number<=ctxNumberofPasses),
    "min",ctxMinRecID+((Number-1)*500),
    "max",ctxMinRecID+(Number*500)
    )
)

This means, "Create a collection of numbers that will be used for telling PowerApps how many times to get 500 records at a time. For each n, pre-determine what minimum to maximum range of id numbers would be."

 

Then you would revise your collection of records to reference the min and max.

Clear(colMiniCaseList);

ForAll(colNumbersTable,
    Collect(colMiniCaseList,
        Filter('eRad Cases',
            miniID>=min,
            miniID<max
        )
    )
)

While this scenario is possible, I am curious why you are using a combination of SharePoint and SQL in this way. If you migrate your data to SQL which you already have, you can create SQL Views to aggregate your data in commonly used views. 

https://powerapps.microsoft.com/en-us/blog/using-sql-server-views-in-powerapps/

 

You'll find that when you bring in tens or hundreds of thousands of records into your app, it will take a performance hit. This is why even first party apps page their data.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 169 members 5,019 guests
Please welcome our newest community members: