cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MB
Level: Powered On

Patch error when patching from a collection back to its source

Getting an error when patching from a collection back to its source as follows:
 
Dropdown1 OnChange:
ClearCollect(MHD,Filter(<Sharepoint list name>,<field name>=Dropdown1.Selected.Result))
 
Patch various fields (but never the modified field) in the collection based on user input into TextInput boxes when changed, then when user is ready they click a Save Icon.
 
Save icon, OnSelect:
Patch(<Sharepoint list name>,MHD)
 
Error:
Modified: The specified column is read-only and can't be modified.
 
Errors(<Sharepoint list name>)
.Column = Modified
.Error = 10
 

1 ACCEPTED SOLUTION

Accepted Solutions
MB
Level: Powered On

Re: Patch error when patching from a collection back to its source

Thanks for getting back to me.  I used ShowColumns to get all columns ex the 'system' ones into the Collection.  I was then able to execute patch(sharepoint list, collection) successfully without an error message, and without having to individually name all the columns in the patch statement.  Probably not much difference, but seems less typing not having to explicitly name them in the patch statement.

View solution in original post

6 REPLIES 6
PowerAddict
Level 10

Re: Patch error when patching from a collection back to its source

The problem is that in your collection you have all the values of the SP list including the modified column. So when you try to patch the collection back without explicitly telling it which columns to patch, it thinks you are trying to patch ALL columns. I would suggest specifying individual columns and use the FirAll function with Patch to patch all items within your collection to SP.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
Community Support Team
Community Support Team

Re: Patch error when patching from a collection back to its source

Hi @MB ,

Do you want to patch your collection data back to your SP List?

 

Based on the formula you provided, I think there is something wrong with it. The 'Modified' column ('Created', 'Created By', 'Modified By', ...) in SP list is a System field, which would be populated by SP System automatically. And the 'Modified' column ('Created', 'Created By', 'Modified By', ...) is Read-Only in PowerApps app, we could not specify a value for it manually.

 

I have made a test on my side, please consider take a try with the following workaround:

1. If you want to patch your MHD collection data as New records into your SP List, please consider modify your formula as below:

ForAll(
       MHD,
       Patch(
             'SPList',
             Defaults('SPList'),
             {
               Column1: MHD[@Column1],
               Column2: MHD[@Column2],
               Column3: MHD[@Column3],
               ...
             }
       )
)

 

2. If you want to update these records in your SP List using the MHD collection, please modify your formula as below:

ForAll(
       MHD,
       Patch(
             'SPList',
             LookUp('SPList', ID = MHD[@ID]),
             {
               Column1: MHD[@Column1],
               Column2: MHD[@Column2],
               Column3: MHD[@Column3],
               ...
             }
       )
)

Note: You could not specify System fields from SP List within '{}' part of above Patch function.

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
PowerAddict
Level 10

Re: Patch error when patching from a collection back to its source

Hi @MB the reply above uses the same approach as suggested by me AND also specifics the formulae to be used.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
MB
Level: Powered On

Re: Patch error when patching from a collection back to its source

Thanks for the replies.  I was trying to avoid patching each field by listing them individually, and found doing it this way does in fact update the list.  It’s just that it generates the error message.

 

Any ideas on how to ignore/clear the message before users see it?  Otherwise I will revert to patching the list directly as fields are updated, or workaround it as you suggested if I opt to keep the collection method.

 

Personally I think it would be helpful if the function ignored ‘system generated’ fields.

Community Support Team
Community Support Team

Re: Patch error when patching from a collection back to its source

Hi  @MB ,

Have you taken a try with the solution I provided above? Do you mean it would generate error message?

 

Based on the needs that you mentioned, I think the solution I provided above could achieve your needs. When you patch the whole MHD collection as argument within the Patch function, it would not ignore ‘system generated’ fields automatically.

 

As an alternative solution, you could consider select these columns you want to save within the MHD collection when you set up your MHD collectioon.

Please consider modify your formula as below:

ClearCollect(
             MHD,
             ShowColumns(
                         Filter(<Sharepoint list name>, <field name>=Dropdown1.Selected.Result),
                        "Title",
                        "Column2",
                        "Column3",
                         ....
            )
)

Note: Do not specify System fields within above ShowColumns function.

 

Then you could modify your formula as below:

Patch(<Sharepoint list name>, Defaults(<Sharepoint list name>), MHD)  // Add new records

If you want to update your SP List records based on the MHD collection, you should take a try with the solution I provided in previous reply (update fields value one by one).

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MB
Level: Powered On

Re: Patch error when patching from a collection back to its source

Thanks for getting back to me.  I used ShowColumns to get all columns ex the 'system' ones into the Collection.  I was then able to execute patch(sharepoint list, collection) successfully without an error message, and without having to individually name all the columns in the patch statement.  Probably not much difference, but seems less typing not having to explicitly name them in the patch statement.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,124)