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
Solved! Go to Solution.
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.
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,
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.
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,
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.
User | Count |
---|---|
251 | |
102 | |
94 | |
48 | |
37 |