Skip to main content
Community site session details

Community site session details

Session Id : MOnWKRZ15KbZbeg+rFXxo9
Power Apps - Building Power Apps
Answered

Delegation Problems

Like (0) ShareShare
ReportReport
Posted on 20 Jun 2024 11:43:49 by 1,105 Super User 2025 Season 2

Greetings!

 

I am having some trouble trying to make a sortable gallery . . . I have a header on the column that that will change a variable to alter the sort column and sort order for each column, for it's gallery bellow. However with the current formulas I'm using, it's causing me delegation errors, which I am not able to solve on my own for now . . . Here's as much as info as I can give on the situation!

 

What I'm trying to do

AmnAA_0-1718883903801.png

 

 

Column OnSelect Property (Changing "EID" for other values on each column)

If(
 varSort <> "EID";
 UpdateContext(
 {
 varSort: "EID";
 varSortOrder: "None"
 }
 )
);;
If(
 varSortOrder = SortOrder.Ascending;
 UpdateContext({varSortOrder: SortOrder.Descending});
 varSortOrder = SortOrder.Descending;
 UpdateContext({varSortOrder: "None"});
 varSortOrder = "None";
 UpdateContext({varSortOrder: SortOrder.Ascending})
)

 

 

Galler Items property

Sort(
 Filter(
 Search(
 'TableGE - Employees';
 compUltimateTextbox_1.value;
 EMPLOYEE_NAME
 );
 Or(
 IsBlank(compUltimateCombobox_1.selectedItems);
 EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME in ShowColumns(
 compUltimateCombobox_1.selectedItems;
 Value
 )
 )
 );
 Switch(
 varSort;
 "EID";
 EMPLOYEE_ID;
 "ENAME";
 EMPLOYEE_NAME;
 "ERESPONSIBLE";
 EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME
 );
 Switch(
 varSortOrder;
 "ascending";
 SortOrder.Ascending;
 "descending";
 SortOrder.Descending;
 "None";
 "None"
 )
)

 

 

Non-delegable part of the gallery code

AmnAA_2-1718883768385.png

 

 

If there is any other way to achieve what I'm doing while retaining the delegation, or any code-fix I can implement on this, I'll be very thankful . . . For now I'll keep trying to fix it on my own, but a little help never hurts!

  • Verified answer
    DBO_DV Profile Picture
    4,665 Super User 2025 Season 2 on 20 Jun 2024 at 16:08:57
    Re: Delegation Problems

    Hey @AmínAA

     

    the Problem is the Switch here is the link. It is Not delegable with functions or multiple columns in it.

     

    The switch needs to be outside just like you did.

    for your lookup column you can basically use lookups or filters to simulate the relationships without breaking it in dataverse.

     

    test it out and have a nice evening.

     

     

  • Verified answer
    AmínAA Profile Picture
    1,105 Super User 2025 Season 2 on 20 Jun 2024 at 12:27:53
    Re: Delegation Problems

    Greetings @DBO_DV, long time no speak!

     

    Sure, I am currently using Dataverse with three columns, two of which are Text columns, those being EMPLOYEE_ID & EMPLOYEE_NAME, and one being a lookup column, that one being EMPLOYEE_RESPONSIBLE. From which I'll later derive the responsible name with EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME . . . Now I managed to fix the delegation problems (almost all of them) with a probably unnecesarily big and redundant code, but I still have one delegation problem . . .

     

    ITEMS PROPERTY OF GALLERY

    Switch(
     varSort;
     "EID";
     Sort(
     Filter(
     Search(
     'TableGE - Employees';
     selCompUltimateTextboxSearch.value;
     EMPLOYEE_NAME
     );
     Or(
     IsBlank(selCompUltimateComboboxResponsible.selectedItems);
     EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME in ShowColumns(
     selCompUltimateComboboxResponsible.selectedItems;
     Value
     )
     )
     );
     EMPLOYEE_ID;
     Switch(
     varSortOrder;
     "ascending";
     SortOrder.Ascending;
     "descending";
     SortOrder.Descending;
     "None";
     "None"
     )
     );
     "ENAME";
     Sort(
     Filter(
     Search(
     'TableGE - Employees';
     selCompUltimateTextboxSearch.value;
     EMPLOYEE_NAME
     );
     Or(
     IsBlank(selCompUltimateComboboxResponsible.selectedItems);
     EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME in ShowColumns(
     selCompUltimateComboboxResponsible.selectedItems;
     Value
     )
     )
     );
     EMPLOYEE_NAME;
     Switch(
     varSortOrder;
     "ascending";
     SortOrder.Ascending;
     "descending";
     SortOrder.Descending;
     "None";
     "None"
     )
     );
     "ERESPONSIBLE";
     Sort(
     Filter(
     Search(
     'TableGE - Employees';
     selCompUltimateTextboxSearch.value;
     EMPLOYEE_NAME
     );
     Or(
     IsBlank(selCompUltimateComboboxResponsible.selectedItems);
     EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME in ShowColumns(
     selCompUltimateComboboxResponsible.selectedItems;
     Value
     )
     )
     );
     EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME;
     Switch(
     varSortOrder;
     "ascending";
     SortOrder.Ascending;
     "descending";
     SortOrder.Descending;
     "None";
     "None"
     )
     );
     Sort(
     Filter(
     Search(
     'TableGE - Employees';
     selCompUltimateTextboxSearch.value;
     EMPLOYEE_NAME
     );
     Or(
     IsBlank(selCompUltimateComboboxResponsible.selectedItems);
     EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME in ShowColumns(
     selCompUltimateComboboxResponsible.selectedItems;
     Value
     )
     )
     );
     EMPLOYEE_NAME;
     Switch(
     varSortOrder;
     "ascending";
     SortOrder.Ascending;
     "descending";
     SortOrder.Descending;
     "None";
     "None"
     )
     )
    )

     

    CURRENT DELEGATION PROBLEM

    AmnAA_0-1718886425169.png

     

     

    Should you, or anyone find a fix before me for the delegation, and or the probably unnecesarily big and redundant code, I'm all ears . . .

  • AmínAA Profile Picture
    1,105 Super User 2025 Season 2 on 20 Jun 2024 at 12:21:15
    Re: Delegation Problems

    [DUPLICATED]

  • AmínAA Profile Picture
    1,105 Super User 2025 Season 2 on 20 Jun 2024 at 12:15:33
    Re: Delegation Problems

    [DUPLICATED]

  • DBO_DV Profile Picture
    4,665 Super User 2025 Season 2 on 20 Jun 2024 at 12:09:22
    Re: Delegation Problems

    Hey @AmínAA ,

     

    Can you tell me what the database is?

     

  • AmínAA Profile Picture
    1,105 Super User 2025 Season 2 on 20 Jun 2024 at 11:59:16
    Re: Delegation Problems

    Greetings @anandm08!

     

    Thank you for the quick response, however, after adjunsting the code to my App and language I still have the same Delegation problem . . .

     

    ADJUSTED CODE

    SortByColumns(
     Filter(
     'TableGE - Employees';
     StartsWith(
     EMPLOYEE_NAME;
     compUltimateTextbox_1.value
     ) && (IsBlank(compUltimateCombobox_1.selectedItems) || EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME in ShowColumns(
     compUltimateCombobox_1.selectedItems;
     Value
     ))
     );
     Switch(
     varSort;
     "EID";
     "pfx_employee_id";
     "ENAME";
     "pfx_employee_name";
     "pfx_employee_id"// Default sort column
     );
     varSortOrder
    )

     

     

    DELEGATION PROBLEM

    AmnAA_0-1718884720714.png

     

    While I did try before using SortByColumns I did not use this sort of filtering, however it still doesn't do the job 😞

  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on 20 Jun 2024 at 11:48:39
    Re: Delegation Problems

    hi @AmínAA ,

    try this:

    SortByColumns(
     Filter(
     'TableGE - Employees',
     StartsWith(EMPLOYEE_NAME, compUltimateTextbox_1.Text) &&
     (
     IsBlank(compUltimateCombobox_1.SelectedItems) ||
     EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME in ShowColumns(compUltimateCombobox_1.SelectedItems, "Value")
     )
     ),
     Switch(
     varSort,
     "EID", "EMPLOYEE_ID",
     "ENAME", "EMPLOYEE_NAME",
     "ERESPONSIBLE", "EMPLOYEE_RESPONSIBLE.RESPONSIBLE_NAME",
     "EMPLOYEE_ID" // Default sort column
     ),
     varSortOrder
    )

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Loading complete