microsoft-teams-apps-buildingaccess icon indicating copy to clipboard operation
microsoft-teams-apps-buildingaccess copied to clipboard

Updateif - delegation issue/limit

Open bungleweed opened this issue 4 years ago • 2 comments

I have a customer that has over 500 items in the BAR_Requests list. When they withdraw a full day request it only marks the full day slot as withdrawn and inactive and not the 2 other slots. I believe this is being caused by a delgation issue with the updateif function being used when withdrawing a request if your request items in the list reside in a item number >500 items.

This is code that is non delegable causing the issue with Full Slot booking not being properly withdrawn:

image

Code needs to be rewritten to a function that supports delegation as using SharePoint list as data source.

bungleweed avatar Sep 06 '21 19:09 bungleweed

I modified the code like this not using UpdateIf which is not delegable creating a collection with Filter that is delegable and then FarAll + Patch on the specific records ID There ara no warning of delegate issue hoping it work correctly

ClearCollect( colUserRequestsSet; Filter( BAR_Requests; IsSlotBooked; RequestorGuid = varUser.id; RequestDate >= Today(); varSelectedRequest.BuildingID = varSelectedBuilding.ID; varSelectedRequest.SpaceName = SpaceName; varSelectedRequest.Request_x0020_Collection_x0020_I = 'Request Collection ID'; varSelectedRequest.DateValue = DateValue

    )

);;

If( varSelectedRequest.TimeSlot = varStringNew.FullDayLbl2; ForAll(colUserRequestsSet; Patch(BAR_Requests; {ID: ThisRecord.ID}; { Status: { '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"; Id: 3; Value: "Withdrawn" }; Active: 0 } ) )

;
Patch(
    BAR_Requests;
    {ID: varSelectedRequest.ID};
    {
        Status: {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference";
            Id: 3;
            Value: "Withdrawn"
        };
        Active: 0
    }
)

);; Set( varShowLoading; false );;

MarcoGIns avatar Jan 23 '22 16:01 MarcoGIns

I've tried what you have suggested @MarcoGIns but I get number the same error as before, I've replaced a few of your ";" with "," to remove the errors in the code when pasting it in to the query.

I still get a delegation warning using the Filter method on large datasets and running through the ClearCollect it fails to get any data.

Cutdown version of the code I've tried

` ClearCollect( colUserRequestsSet, Filter( BAR_Requests, varSelectedRequest.Request_x0020_Collection_x0020_I = 'Request Collection ID'; ) );

ForAll(colUserRequestsSet; Patch( BAR_Requests, {ID: ThisRecord.ID}; { Status: { '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: 3, Value: "Withdrawn" }, Active: 0 } ); `

mdlister avatar Jan 25 '22 17:01 mdlister