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

network error when using patch function : the specified column is read-only and can't be modified

Hi there,

I'm having a problem with a patch(myList, myCollection) function. I'm using a canva app that collects records from a Sharepoint list in a collection.
Users of my app can update rows locally, and when they want, sync the app with the list.

The application is deployed on multiple devices.

The error message occurs after an indefinite time, and not on all devices. If the user restarts the app, it works again.
Error message : "network error when using patch function : the specified column is read-only and can't be modified"
I do not have set any readonly colomn on my list, and removed all additionnals lookup columns, which I thought were causing the error.

I have seen this post

but the proposed solution doesn't suit me, since the 

patch(myList, myCOllection)

internally checks whether rows have changed or not, and updates only those that have changed. Whereas

Patch(SharePointList,ShowColumns(myCollection,"Column1","Column2","Column3"))

or

ForAll(
 mycollection
 Patch(SharePointList,Defaults(SharePointList),{Column1:Column1,Column2:Column2})
)

 updates all rows, modified or not, which may overwrite data.

Any ideas ?
Thanks !

1 ACCEPTED SOLUTION

Accepted Solutions
Nao_
Helper II
Helper II

Hi @WarrenBelz ,
I don't understand how the patch() function knows which items have been modified and only creates a new version for them, while the other two solutions create a version for all items even having the id.

For my original concern, I actually suspect either connectivity or data in MyCollection that may have been corrupted. But no idea how to test this. Maybe my last solution will be to create a ticket

 

Thanks for taking the time to respond to my post.

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

Hi @Nao_ ,

Dealing with the issues individually - it is a bit hard to isolate the error if it is intermittent, however to clarify your options

Patch(
   myList, 
   myCollection
)

assuming the unique identifier (ID) is present in the collection will update the list with all records in the collection with the content of the matching record - there is actually no checking done, but that is irrelevant here. 

Patch(
   SharePointList,
   ShowColumns(
      myCollection,
      "Column1",
      "Column2",
      "Column3"
   )
)

Will create new records with those 3 column values in the respective fields - assuming none of those columns are the ID.

ForAll(
    mycollection
    Patch(
      SharePointList,
      Defaults(SharePointList),
      {
         Column1: Column1,
         Column2: Column2
         Column3: Column3
      }
   )
)

 will do exactly the same as the one above except you would have a potential ambiguity issue with identical column names. If you want to update the fields in the list, you would do this

Patch(
   SharePointList,
   ForAll(
       mycollection As aPatch,
      {
         ID: aPatch.ID,
         Column1: aPatch.Column1,
         Column2: aPatch.Column2,
         Column3: aPatch.Column3
      }
   )
)

 

Please click Accept as solution 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 Thumbs Up.

Visit my blog Practical Power Apps

 

Nao_
Helper II
Helper II

Hi @WarrenBelz , thanks for your answer !

I don't know exactly how the patch(myList, myCollection) works, I just tested the possibilities and when using the patch(myList, myCollection) I don't have new versions for all list items , only those modified by the device. The other two solutions create a new version for all the items in the list. And that's why I have to use the patchpatch(myList, myCollection) function.

 

Any idea why I get this error message occasionally?

@Nao_ ,

To briefly explain it, if your collection includes the ID (unique identifier) then

Patch(myList, myCollection)

will update any existing records where the ID's match (which of course will be every item in the collection). The other two do not include the ID and therefore having nothing to match will create new records.

As I said initially, an intermittent error is the hardest to solve as it generally cannot be replicated and other than to say (if you do not have any  read-only records other than the ID) should not happen. However the practice of "letting SharePoint sort it out" with a bulk Patch while correct in syntax, maybe should be replaced with "doing it the long way" and specifying the columns (source and destination) if it is erroring for you at times.

 

Please click Accept as solution 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 Thumbs Up.

Visit my blog Practical Power Apps

WarrenBelz
Super User
Super User

Hi @Nao_ ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution 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 Thumbs Up.

Visit my blog Practical Power Apps

Nao_
Helper II
Helper II

Hi @WarrenBelz

 

I would like to clarify that I had included the ID in the ForAll() and ShowColumns() functions. I didn't have new items created for existing items, but new versions (in the SP list, click on the item, then "Version History") for all items, not just those that had a modification . That's why I can't use these systems to specify the columns for the patch() function.

 

But I guess if it's impossible not to have new version of list items, or to debug my intermittent error, I'll have to find another system to update my SP list via my app. Unless someone has another idea to try?


thanks !

 

Hi @Nao_ ,

You have Patched all items - Power Apps has no way of knowing which are changed unless you want to deal with a whole new level of complexity and flag anything changed in another field and then filter on this flag. I would suspect your intermittent error is connectivity (at the time) related.

Nao_
Helper II
Helper II

Hi @WarrenBelz ,
I don't understand how the patch() function knows which items have been modified and only creates a new version for them, while the other two solutions create a version for all items even having the id.

For my original concern, I actually suspect either connectivity or data in MyCollection that may have been corrupted. But no idea how to test this. Maybe my last solution will be to create a ticket

 

Thanks for taking the time to respond to my post.

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

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 (4,191)