Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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!

  • CU-18081211-6 Profile Picture
    9,266 Super User 2025 Season 1 on at
    Error When Applying Patch to a Collection in Power Apps with SharePoint Data
    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 !
  • WarrenBelz Profile Picture
    146,596 Most Valuable Professional on at
    Error When Applying Patch to a Collection in Power Apps with SharePoint Data
    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,596 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard