cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Delminium
Helper II
Helper II

Problems Updating SharePoint List using ForAll/Patch

Hello,

 

I am having an issue with some code that used to work but is now giving me errors when I attempt to run it via a button click.

 

The only change I made was to one of my flows. The flow trigger was changed to point to a new SharePoint List. I have tried recreating my button and creating a new flow from scratch.

 

When I click the button, I get the following error message:

 

The requested operation is invalid. Server Response: Order_Details failed: Fetching items failed. Possible invalid string in filter query. clientRequestId: 78beb383-53d2-4351-b4cf-6f54524af010 serviceRequestId: 78beb383-53d2-4351-b4cf-6f54524af010

 

If I remove the code below then I don't have any issues. The code appears to be correct in PowerApps. I am not sure why this is suddenly occurring. Hoping someone else knows!

 

 

ForAll(colOrderDetails,
Patch(Order_Details,LookUp(Order_Details,ID=colOrderDetails[@ID]),
{
    OrderNo:colOrderDetails[@OrderNo],
    LineNo:colOrderDetails[@LineNo],
    ItemNo:colOrderDetails[@ItemNo],
    ItemDescription:colOrderDetails[@ItemDescription],
    QtyOrdered:colOrderDetails[@QtyOrdered],
    QtyReceived:colOrderDetails[@QtyReceived],
    QtyDamaged:colOrderDetails[@QtyDamaged],
    ReceivedBy:If(colOrderDetails[@QtyReceived]<>0,User().FullName,""),
    ReceivedDate:If(colOrderDetails[@QtyReceived]<>0,DateAdd( Now(), 0, Hours ),"")
}
));

 

  Thanks to all in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

@Helen_BB 

 

Correction:

 

Needed to update the line:

 

Patch(Order_Details,glryOrderDetails.Selected,

to

Patch(Order_Details,{ID: colOrderDetails[@ID]},

 

The top line was overwriting data with the last item in my gallery.

 

Last line works super.

 

So to rehash, got rid of LookUp(Order_Details,ID=colOrderDetails[@ID] line I had before. Power Apps does not seem like the LookUp function within the Patch function anymore. Using ID: colOrderDetails[@ID] is all that is needed.

 

View solution in original post

26 REPLIES 26
Helen_BB
Helper III
Helper III

Hello @Delminium 

 

I am getting the exact same error on a piece of code that has been working fine for the past year! - the only thing I did today was refreshing my data sources. 

 

been trying to work it out for hours today so I'm glad someone is having a similar issue, maybe something to do with microsoft and not our code? 

 

Set(Loading,true);UpdateContext({vGalleryItems2020:Gallery3.AllItems});ForAll(vGalleryItems2020,Patch('Objectives 2020',LookUp(Filter('Objectives 2020','Chicken Nug Nugs'='Current PDP ID'.Text),ID=vGalleryItems2020[@ID]),{How:vGalleryItems2020[@Howbox].Text,What:vGalleryItems2020[@Whatbox].Text,RAGE:vGalleryItems2020[@'Rag Employee'].SelectedText.Value,RAGM:vGalleryItems2020[@'Rag Manager'].SelectedText.Value,Comments:vGalleryItems2020[@CommentsBox].Text,Empowerment:vGalleryItems2020[@empowerment].Value,Love:vGalleryItems2020[@'Love our products'].Value,Clarity:vGalleryItems2020[@clarity].Value,Dynamic:vGalleryItems2020[@'Dynamic & Agile'].Value}));Refresh('Objectives 2020');Set(Loading,false)

 

 

Hello @Helen_BB!

 

Glad I am not alone! I googled for a solution to my problem so it seems like it is fairly new.

 

I updated to the latest authoring version (3.20071.22) but I am still getting the same error.

Let's hope someone enlightens us soon! It's so frustrating! - let me know if you figure it out.

 

Thanks 🙂

 

Hello @Helen_BB 

 

The only thing I can tell is that my app was working properly under version 3.20061.27.

 

The lowest available version now is 3.20063.13 and I still get the same problem.

 

@Delminium 

Mine had been working fine until yesterday! the app is used almost every day across the business. Just checked again today and still not working, had my fingers crossed it would magically fix overnight!  

@Helen_BB 

 

Mine was working fine until I came back from vacation this week. The only tweak I made was to one of my flows (could this be the reason?). The code in question stopped working once I changed the trigger to this flow. The original trigger was the SharePoint list that the code is trying to update. The new trigger is now a new SharePoint list because my workflow was getting some failures due to locking issues.

 

I tried numerous things that all failed yesterday:

 

  • Creating a new button with the same code
  • Exporting the app and then re-importing it as a differently named app.
  • Creating a whole new SharePoint list with the same data
  • Disabling the old workflow and creating a whole new workflow with the new trigger

The only thing that worked was reverting back to the original workflow configuration, which works but is not helpful because I really need to update the trigger on that workflow to point to a different SP list.

 

I have about 2 weeks left before I am supposed to release this app into production and at this point I'm not sure what I need to do. I'll try a few more things today but I am slowly running out of ideas.

 

Hopefully someone else will chime in with some more ideas.

@Helen_BB 

 

Just an update. I created a new button on a different screen with the following code.

 

 

ForAll(colOrderDetails,
Patch(Order_Details,LookUp(Order_Details,ID=colOrderDetails[@ID]),
{
    OrderNo:colOrderDetails[@OrderNo],
    LineNo:colOrderDetails[@LineNo],
    ItemNo:colOrderDetails[@ItemNo],
    ItemDescription:colOrderDetails[@ItemDescription],
    QtyOrdered:colOrderDetails[@QtyOrdered],
    QtyReceived:colOrderDetails[@QtyReceived],
    QtyDamaged:colOrderDetails[@QtyDamaged],
    ReceivedBy:If(colOrderDetails[@QtyReceived]<>0,User().FullName,""),
    ReceivedDate:If(colOrderDetails[@QtyReceived]<>0,DateAdd( Now(), 0, Hours ),"")
}
));

 

 

This time I am seeing an error related to the Lookup part of the Patch function:

 

The requested operation is invalid. Server Response: Order_Details failed: Fetching items failed. Possible invalid string in filter query. clientRequestId: d44e731c-3758-4deo-8046-a0af546e46db serviceRequestld: d44e731c-3758-4deo-8046-aoaf546e46db

 

Not sure why this is occurring all of a sudden. For the record, I create my collection colOrderDetails from the SP list at the App OnStart event. Each field data type should be the same.

@Helen_BB 

 

I think I found a workaround which goes like this:

 

UpdateIf(colOrderDetails,colOrderDetails[@QtyReceived]<>0,
{
    ReceivedBy:User().FullName,
    ReceivedDate:DateAdd( Now(), 0, Hours )
}
);

Collect(Order_Details,colOrderDetails);

 

First I update the two conditional fields in my collection using UpdateIf. If will only update those records in my collection where QtyReceived<>0.

 

Then I do away with the ForAll/Patch combo and use a simple one line solution to update my SharePoint list using all the records in my collection.

 

Easy peasy lemon squeezy 😎

 

Maybe you can incorporate something similar? I'm going to test this some more before I accept it as the solution.

@Helen_BB 

 

I think I spoke too soon.

 

The new workaround seems to fail too.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,345)