Hello All,
I have a problem as my patch function is not working and I am not sure what to do now. The error message says:
"The data source is read-only or has no primary key, so the function Patch can't write to it."
my code is: Patch(Table10, {Comment: L2_Comment.Text})
data source is excel file on OneDrive but even if I tried to re connect from one drive not excel it's still not working.
What should I do, please?
Thanks in advance.
Ok now I am 100% sure it is connected to One Drive my account as I checked with IT. New error is:
"The requested operation is invalid. Server Response: Table10 failed: A value must be provided for item"
...actually I have this file on desktop bit ideally I should access one of our drives where the file should be and I can't see that option in data source-> OneDrive for Business:
Hi, yes I can edit it in Excel sheet and modify it. The accounts are the same and now I have just disconnected excel file completely and connected again to it through OneDrive and my error on patch function is now saying:
"The requested operation is invalid. Server Response: Table10 failed: A value must be provided for item"
As I tried to input: Hello! as a Comment in input box so it can add it to a file but did not work either.
Hi @marcy_pi,
Do you mean that you could directly edit the excel table in the Excel sheet?
Have you checked if the account of the OneDrive connection from Power Apps is the same as the account you access to the Excel sheet on OneDrive?
In addition, do you only connect to the Excel file using the OneDrive connector?
Hi thank You for Your message. I am not sure how to check this but excel file which is my data source is file which I am editing and modifying on daily basis so I guess I have permissions to it through the app as well?
Hi thank You, so I've done this:
Patch( Table10, Defaults( Table10 ), { Comment: TextInput2 } )
Where:
- Table10 is my datasource from excel
- Comment is ThisItem.Comment in Gallery
- TextInput2 is a box for comments which I inputted to my app.
Error I get is exactly the same as I describe so still as read-only or no primary key...
Hi @marcy_pi,
Could you please check your account to see if it has access to the excel file on the OneDrive?
Go to your connection and check the account you connect to the OneDrive, make sure that this account has enough permission to access to the data source.
In addition, remove the ExcelOnline connector but only keep the OneDrive connector.
Hi @marcy_pi ,
use Patch with the Defaults function to create records.
Example: Patch( Customers, Defaults( Customers ), { Name: "Contoso" } )