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

Notifications

Announcements

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
    153,084 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard