web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Delegation

(0) ShareShare
ReportReport
Posted on by 130

I have created an app based on Sharepoint lists with a limit of 2000 rows regarding delegation...

One of my lists contains currently approx. 3000 rows of data, and it will keep on increasing ( = delegation is very relevant)...

 

In my app I have a button in a gallery, that is to update those rows of data which meets a given sets of criterias.

I have writen this code, where I have created a filter within a filter, as I assume that the blue part in a filter could cause problems related to delegation... (otherwise I could have all the informations in the same filter)

 

---------------

ForAll(
Filter(Filter(Table_Tasks;SagNummer=ThisItem.SagNummer;Status=10);";"&ThisItem.TaskNummer&";" in Predecessor);
Patch(Table_Tasks; ThisRecord;
{Predecessor: Substitute(ThisRecord.Predecessor; ";"&ThisItem.TaskNummer&";"; "" );
Status: If(ThisRecord.Predecessor = ";"&ThisItem.TaskNummer&";"; 20; 10);
Tasks_ChangedBy:CurrentUsername;
Tasks_ChangedDate:Now()}
))

---------------

 

"Table_Tasks" contains approx. 3000 rows of data

"SagNummer=ThisItem.SagNummer" reduces the rows of data to max 13 rows

"Status=10" and ";"&ThisItem.TaskNummer&";" in Predecessor reduces the rows of data to those which is to be updated with Status = 20 and ";"&ThisItem.TaskNummer&";" is to be removed from the Predecessor...

 

It seems to fail from time to time (not always), so I don't know if delegation could be the problem... 

 

If delegation is not the problem - is there a way to see, what has happend since the code wasn't carried out correctly, when the user pressed the button? (The app control center where errors and performance can be tracked shows nothing as it works fine, when I test the system, but when it fails with another user, I would like to see some kind of log, showing why nothing is being changed when the button is pressed)

 

Thanks in advance

 

Wkr Jørgen

Categories:
I have the same question (0)
  • NPPlatform Profile Picture
    606 Moderator on at

    Hi, in case this is a delegation issue you might be able to work around it by using With(). See the formula below:

     

    With({baseTable: Filter(Table_Tasks;SagNummer=ThisItem.SagNummer;Status=10)
    },
    ForAll(
    Filter(baseTable;";"&ThisItem.TaskNummer&";" in Predecessor);
    Patch(Table_Tasks; ThisRecord;
    {Predecessor: Substitute(ThisRecord.Predecessor; ";"&ThisItem.TaskNummer&";"; "" );
    Status: If(ThisRecord.Predecessor = ";"&ThisItem.TaskNummer&";"; 20; 10);
    Tasks_ChangedBy:CurrentUsername;
    Tasks_ChangedDate:Now()}
    )))

    This formula will seperate the delegable part of the formula, store the result of that formula and use this result for further actions.

     

    Regarding logging what happens when a user clicks a button, you can read this article by Matthew Devaney about logging and error handling: https://www.matthewdevaney.com/power-apps-coding-standards-for-canvas-apps/power-apps-error-handling-guidelines/

  • Rajkumar_M Profile Picture
    3,741 Super User 2025 Season 2 on at

    Hi @jlke-as 

     

    Refer this link this may help you : https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/delegation-overview

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • jlke-as Profile Picture
    130 on at

    Hi NPPlatform

     

    Thanks for your reply...

    If I use my one formular will I then avoid delegation... (the solution with a filter within a filter)...?

     

    Wkr

    Jørgen

  • NPPlatform Profile Picture
    606 Moderator on at

    I'm not 100% sure, but 99% sure that your solution does not avoid delegation. In your case the whole formula

    Filter(Filter(Table_Tasks;SagNummer=ThisItem.SagNummer;Status=10);";"&ThisItem.TaskNummer&";" in Predecessor)

    is sent to the datasource for evaluation. In my case only the With-statement is sent to the datasource. The response of the datasource is then stored and used in the rest of the formula.

     

    I have just tried it in PowerApps. The formula with your structure does give a delegation warning (see the yellow triangle in screenshot 1 below). The formula with my structure does not give a delegation warning.

    Screenshot 1:

    NPPlatform_0-1707384964029.png

    Screenshot 2:

    NPPlatform_1-1707385023140.png

     

    Hope this helps!

     

  • jlke-as Profile Picture
    130 on at

    Hi again

     

    Now I took look at the MatthewDevaney link, which you sent...

    It makes sence if the code fails to use the "iferror on patch" if the code fails...

     

    But in my case it appears not to fail - it just don't complete the task...

     

    Eg. the code below... (the button in the gallery has 3 tasks to complete... The user has no restrictions... From time to time the the 2nd and 3rd part of the code is not done...)

     

    I will try the "iferror on patch" to see if I will learn more, but I am affraid that an "error" will never occour...)

    ---------

     

    If(CountRows(Filter(Table_Tasks;SagNummer=ThisItem.SagNummer;Status<40))=1;

    Patch(Sager;LookUp(Sager;SagNummer=BrowseGallery1_2.Selected.SagNummer);{Sager_Status: "Gennemført"})
    )

    ;;

    ForAll(
    Filter(Filter(Table_Tasks;SagNummer=ThisItem.SagNummer;Status=10);";"&ThisItem.TaskNummer&";" in Predecessor);
    Patch(Table_Tasks; ThisRecord;
    {Predecessor: Substitute(ThisRecord.Predecessor; ";"&ThisItem.TaskNummer&";"; "" );
    Status: If(ThisRecord.Predecessor = ";"&ThisItem.TaskNummer&";"; 20; 10);
    Tasks_ChangedBy:CurrentUsername;
    Tasks_ChangedDate:Now()}
    ))

    ;;

    Patch(Table_Tasks;ThisItem;{Status:40;Tasks_ChangedBy:CurrentUsername;Tasks_ChangedDate:Now()})

     

    ---------

  • jlke-as Profile Picture
    130 on at

    Hi again

     

    The solution with "iferror on patch" did not work...

    From time to time the system still fails - without completing the navigation to the "error-page"...

     

    I will now try the "with"-solution.. (And cross my fingers)...

     

    However... What could be the reason for this code to not be carried out correctly every time...?

    (is is a button within a gallery - and I can hardly use the "with"-solution here...)

    Patch(Table_Tasks;ThisItem;{Status:40;Tasks_ChangedBy:CurrentUsername;Tasks_ChangedDate:Now()})

     

    I almost give up... 😉

     

    Wkr Jørgen

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard