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 / Patch function on view
Power Apps
Answered

Patch function on view

(0) ShareShare
ReportReport
Posted on by 43

Can we add patch function on view in power apps? Since view doesn't have primary key, patch function can't be applied when a view is used as a data source. So is there any work around for this scenario?

Categories:
  • Verified answer
    MaximusDecimus Profile Picture
    281 on at

    Hi @Simran1607 ,

     

    There is a workaround indeed. Update your view to include the primary key for the table(s) you want to patch and slightly amend you patch so it looks similar to the below:

     

    Patch(dataSource, LookUp(dataSource, ID = ThisItem.IDFK),
     {
     Column1: patchValue
     }
    )

    The lookup returns a record which can be used in the patch. This above example is for a gallery but if you're using something else then just set the ID value to a variable and use that in the lookup.

  • Simran1607 Profile Picture
    43 on at

    Thanks @MaximusDecimus for the suggestion. Can you kindly also mention which is the column that must be created as unique column in the view table? Is it "IDFK" or "Column1"?

  • MaximusDecimus Profile Picture
    281 on at

    You can call the column whatever you like, ideally whatever makes sense to you. I typically call mine IDFK or something more descriptive if I have multiple tables I want to update from the view.

  • Simran1607 Profile Picture
    43 on at

    So what is Column1 in this formula?

     

  • MaximusDecimus Profile Picture
    281 on at

    That just refers to the column you want to update.

  • Simran1607 Profile Picture
    43 on at

    Okay, thank you @MaximusDecimus 

  • Simran1607 Profile Picture
    43 on at

    I am still getting the error "The data source is either read-only or has no primary key, so the function Patch can't write to it.". P.S. I have all the access to the data source

  • MaximusDecimus Profile Picture
    281 on at

    You'll need to set a primary key in the data source you want to patch to.

  • Simran1607 Profile Picture
    43 on at

    UpdateIf(colData, true, {Column1:patchValue}); 

    Patch(view dataSource, colData);

    What if I want to use this specific formula for my view, how can I do the key mapping in this formula?

  • MaximusDecimus Profile Picture
    281 on at

    You'd need to ensure that colData is the same format as your destination table.

     

    This is a good read on patching updates and has great examples.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard