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 / Subsequent Patching to...
Power Apps
Answered

Subsequent Patching to Sharepoint results in the error "Specified column is read-only and cannot be modified."

(0) ShareShare
ReportReport
Posted on by 17

I have an app and I am connected to a Sharepoint list as the datasource. There are many columns, so I split the columns across multiple forms in my app. All of the forms are on one screen. I have created a tabbed view and depending on the tab selected, only the corresponding form is visible. Now, again, only certain columns are shown on the different forms. The Item property of the forms is pointing to a record variable that I have filled with either the defaults from my list (in the case that I want to create a new record) or the selected item from a gallery which shows only summary information about the items in my Sharepoint list (in the case where I want to view/update an existing record).

 

In any case, whenever I open the app, select an item in the gallery, edit a field and then submit the change back to my list, it works the very first time. However, if I try to submit any subsequent changes, it results in the error mentioned in the post header.

 

Here is my patch code which is connected to the OnSelect action of a button on the screen:

 

 

UpdateContext({
 varFormData:
 Patch(
 varFormData
 , formPO_HdrInfo.Updates
 , formPO_PrjInfo.Updates
 , formPO_VendorInfo.Updates
 , formPO_AdditionalInfo.Updates
 , formPO_Attachments.Updates
 )
});

Switch(
 varFormMode
 , 1
 , Set(lookupRecord, Defaults('Purchase Orders'));
 If(
 IsError(
 Patch(
 'Purchase Orders'
 , lookupRecord
 , varFormData
 )
 )
 , Notify(First(Errors('Purchase Orders', lookupRecord)).Error & ": " & First(Errors('Purchase Orders', lookupRecord)).Message, NotificationType.Error)
 , Notify("Purchase Order created successfully!", NotificationType.Information)
 )
 , 2
 , Set(lookupRecord, LookUp('Purchase Orders', ID=varFormData.ID));
 If(
 IsError(
 Patch(
 'Purchase Orders'
 , lookupRecord
 , varFormData
 )
 )
 , Notify(First(Errors('Purchase Orders', lookupRecord)).Error & ": " & First(Errors('Purchase Orders', lookupRecord)).Message, NotificationType.Error)
 , Notify("Purchase Order successfully updated!", NotificationType.Information)
 )
 // Should never happen as Submit button will not be visible in other modes
 , Notify("Cannot submit updates in this mode", NotificationType.Error)
);

 

 

 

In my switch, varFormMode of 1 indicates a new record to be created on the Sharepoint list and a value of 2 means that this is an existing record to be updated.

 

Keep in mind that I do not have any of those read-only Sharepoint fields on any of my forms, so those columns should not exist in my varFormData record variable.

 

I have no idea why this error is happening and no idea on how to fix it. Your help is much appreciated

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,127 Most Valuable Professional on at

    Hi @SignorSoprano ,

    I believe your issue will be a field on more than one form where you have changed it on two forms, therefore the second update will not work as the value it is updating is different from what it was when the form was loaded. If you are going to use the structure you have, it is important that any given field is only editable on one form.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • SignorSoprano Profile Picture
    17 on at

    Well, I do not have any duplicate fields on multiple forms. Should I reset the form after I do the Patch and refresh the dataset?

  • WarrenBelz Profile Picture
    156,127 Most Valuable Professional on at

    @SignorSoprano ,

    OK - I missed one item from your post - you are using a Table Variable at the top (you have the same Set name as you are patching to - I was treating this as a Collection or data source, so disregard my comments on what is the most common error with these.

    Firstly, I believe the offending field may be the ID which will be in an existing record and not in a new one, but I would l not personally approach this the way you have (why not simply submit the forms to the data source ?) and also I only use Record Varibles on static reference lists however you may be able to work on this structure (it is valid) as SharePoint should selectively create a new record or write to the existing item depending on whether a matching ID is in the record. Also I cannot get your top code to validate here.

    ClearCollect(
     colFormData, 
     formPO_HdrInfo.Updates, 
     formPO_PrjInfo.Updates, 
     formPO_VendorInfo.Updates, 
     formPO_AdditionalInfo.Updates, 
     formPO_Attachments.Updates
    );
    If(
     IsError(
     Patch(
     'Purchase Orders',
     colFormData
     ),
    	 Notify(
     First(Errors('Purchase Orders', lookupRecord)).Error & ": " & 
     First(Errors('Purchase Orders', lookupRecord)).Message, 
     NotificationType.Error
     ), 
     Notify(
     "Purchase Order created successfully!", 
     NotificationType.Information
     )
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • SignorSoprano Profile Picture
    17 on at

    Okay. I did the two different patches because all of the examples I have seen showed that for a new record, you patch using defaults and the updates and for an existing record, you look up the record in the list and then patch using that and the updates. I thought there is a better way, but I didn't see anyone doing it like you showed here.

     

    I also didn't use submit for each form to help on performance. I didn't want to submit to the sharepoint list multiple times, so that's why I used the patch. Not sure if that actually improves performance by a significant amount, but that's why I did it that way, regardless.

     

    Anyway, my table variable holds the one record I am showing in the forms. If it is a new record, I initially set the table variable to Defaults('Purchase Orders'). If it is an existing record (via a gallery selection), I set it to the gallery selection. I patch to that variable first before patching to my list because I wanted that variable to still hold the record because I still want to show it in my forms for the user's viewing pleasure or perhaps to update again.

     

    I will try your code and see if that works better. But why use a collection instead of a table variable? I only need one record.

     

    Thanks for your help!

  • WarrenBelz Profile Picture
    156,127 Most Valuable Professional on at

    @SignorSoprano ,

    I use the Collection as I know it works in a Patch to SharePoint when the fields "line up" and it also updates when the ID matches, although looking at it again, does your Variable result in a Record or a Table (I don't have the time to build a model to test it presently and I have never gone down this road).

    If a Table (multiple records which the Collection should generate), the Collection should do the job. If a single record, you somehow have to get the ID (I think that is the culprit) out of your Variable.

  • SignorSoprano Profile Picture
    17 on at

    My variable is a record not a table. Sorry I mistyped earlier when I said table. By "get the ID out of your variable," you mean I need to remove the ID field from my record variable prior to patching?

  • WarrenBelz Profile Picture
    156,127 Most Valuable Professional on at

    @SignorSoprano ,

    Assuming you get a Record with your Variable (I cannot even get it to validate here to test it, but a collection is definitely a Table), the structure you are using is directing Power Apps to a particular data source record (on existing items) and asking it to update this record with every field in the Variable. Your error is that one (or more) of these is fields is read-only and the ID is the obvious culprit.

    I suggest you generate the Variable then have a look and see what fields in there have content.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

     

  • SignorSoprano Profile Picture
    17 on at

    What isn't validating? I can run the app and everything validates for me. But I suppose if you only are trying to validate this one section of code I posted, then I reckon that makes sense.

     

    In any case, I looked at what is in the record variable and there are the hidden, meta-data fields for the Sharepoint list in there. Fields like {FileNameWithExtension}, {FullPath}, {Version}, {Thumbnail}, etc. When I print the offending column in the error message, these are also the columns which are displayed as the offending columns that cannot be modified because they are read-only. Why are these fields in the selected item (and thus my record variable) in the first place?

  • Verified answer
    SignorSoprano Profile Picture
    17 on at

    I have it working, now. I removed the patch for the varFormData at the top and changed the patch for the Sharepoint list to be:

     

    Patch(
     'Purchase Orders'
     , varFormData
     , formPO_HdrInfo.Updates
     , formPO_PrjInfo.Updates
     , formPO_VendorInfo.Updates
     , formPO_AdditionalInfo.Updates
     , formPO_Attachments.Updates
    );

     

     

     

    You helped me to realize that when patching the SP list, the record in the 2nd argument is there only to locate the existing item you want to update. But I was updating my record variable with all of the updates and every field in a list item (although I didn't know the meta-data fields would be there).

     

    Thanks 

  • WarrenBelz Profile Picture
    156,127 Most Valuable Professional on at

    Hi @SignorSoprano ,

    Yes - pretty much what I thought in my last post. What you have done is the same principle as my code with the Collection - you are letting SharePoint sort out whether to update the record (when you have an ID in it) or create a new record.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 335 Most Valuable Professional

#2
11manish Profile Picture

11manish 166

#3
sannavajjala87 Profile Picture

sannavajjala87 71 Super User 2026 Season 1

Last 30 days Overall leaderboard