cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
James_Hellfeier
Helper I
Helper I

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
Mr-Dang-MSFT
Power Apps
Power Apps

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
Anonymous
Not applicable

adding in @Chris to assist 

 

@Anonymous

Drrickryp
Super User II
Super User II

Hey @Anonymous this sounds like a job for @mr-dang

Mr-Dang-MSFT
Power Apps
Power Apps

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (17,008)