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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Error When Applying Pa...
Power Apps
Unanswered

Error When Applying Patch to a Collection in Power Apps with SharePoint Data

(1) ShareShare
ReportReport
Posted on by 2

Hello everyone,

I'm facing an issue while trying to use the Patch function in a gallery populated with data from a SharePoint list.

Scenario:

I have a gallery (Gallery2) that displays data from a SharePoint list. The gallery shows the fields Trilho and Num_Cabine, as shown in Image 1 (attached).

I created a collection (MinhaColecaoComValores) from this gallery using the code below:

Clear(MinhaColecaoComValores);
ForAll(
    Gallery2.AllItems,
    Collect(MinhaColecaoComValores,
        {
            ID: ThisRecord.ID,
            Trilho: ThisRecord.Trilho,
            Num_Cabine: ThisRecord.Num_Cabine,
            ValorAnterior: If(
                CountRows(MinhaColecaoComValores) = 0,
                Blank(),
                Last(MinhaColecaoComValores).Num_Cabine
            )
        }
    )
)

 

The idea here is to collect the Num_Cabine value from the previous row so that it can be used later.

After collecting the data in the collection, I want to use the previous value (ValorAnterior) to update the gallery, where the previous Num_Cabine value is moved to the next row.

I'm trying to do this using the code below:

ForAll(
    MinhaColecaoComValores,
    Patch(
        'Trilho de Cabines Base de Dados',
        LookUp(
            'Trilho de Cabines Base de Dados',
            ID = ThisRecord.ID
        ),
        {Num_Cabine: ThisRecord.ValorAnterior}
    )
)

Problem:

When I run the Patch code, I'm getting the following error:

Error when trying to retrieve data from the network: Fetching items failed. Possible invalid string in filter query.

However, when I replace ThisRecord.ID with a specific number in the ID field in the LookUp, the Patch works normally.

Question:

Could someone help me identify what might be causing this error? Is there any adjustment I need to make in the LookUp or Patch query to avoid this problem?

Thanks in advance for your help!

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,333 Most Valuable Professional on at
    Assuming the ID field is in the collection and the matching ID  is in your data source
    Patch(
    'Trilho de Cabines Base de Dados',
    ForAll( MinhaColecaoComValores As _Data,
      { ID: _Data.ID Num_Cabine: _Data.ValorAnterior
      }
    ​​​​​​​ ) )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • CU-18081211-6 Profile Picture
    9,270 Moderator on at
    May be you should reconsider your approach as Sharepoint might be much permissive in Patch terms.
    Try:
     
    ​
    Patch(
      'Trilho de Cabines Base de Dados',
      ForAll(
           MinhaColecaoComValores As _table,
           {
             ID : _table.ID
             Num_Cabine: _table.ValorAnterior
           }
        )
    )
    Hope it helps !

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 893

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 482

Last 30 days Overall leaderboard