Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

(0) ShareShare
ReportReport
Posted on by 158

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.

 

 

Categories:
  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

    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"

  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

    ...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: 

    marcy_pi_0-1655892614216.png

     

     

  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

    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. 

  • Verified answer
    Re: Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

    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?

  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

    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? 

  • MP-13011217-0 Profile Picture
    MP-13011217-0 158 on at
    Re: Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

    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...  

     

     

  • Re: Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

    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.

  • anibra Profile Picture
    anibra 278 on at
    Re: Patch function not working and shows error message: "The data source is read-only or has no primary key, so the function Patch can't write to it."

    Hi @marcy_pi ,

    use Patch with the Defaults function to create records.

    Example: Patch( Customers, Defaults( Customers ), { Name: "Contoso" } )

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,422

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,711

Leaderboard