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 / Using the dataset API ...
Power Apps
Unanswered

Using the dataset API from a PCF component raises error

(0) ShareShare
ReportReport
Posted on by 173

As per the documentation I am trying to set the value of a field and then save the result. I know that at least @DianaBirkelbach has had success with this as she has blogged about it but also here , both a fair while ago now. 

 

For me though, and it is now November 2022, I get this error on save: Cannot read properties of undefined (reading 'patchAsync')

 

Does anybody know what is missing here? These are new builds off latest versions of libraries (I assume, I am not even sure where this dataset API is found, where is the actual implementation?)

 

I have the same question (0)
  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @camer314 , 

     

    • Do you have a Canvas App/CustomPage or a Model-Driven App?
    • What kind of value do you change before saving? For instance I know about a issue after setting a lookup in a model-driven app...
    • In case your PCF is on a Canvas Apps/CustomPage, what's the source of your data? Is it a Dataverse Table? Or maybe a collection?

     

  • camer314 Profile Picture
    173 on at

    HI @DianaBirkelbach ,

     

    Thanks for the reply, I should have been more clear.

     

    It is a canvas app, the source is a collection and the value I am trying to set is a Boolean.

     

    I had also noticed in the stack trace that the authoring version of your app plays a big part so I would suspect that somewhere they have introduced a bug. Certainly it does not work for me on 3.22103.22 or any release either side.

  • cchannon Profile Picture
    4,702 Moderator on at

    For a PCF embedded in a canvas app, you have two options:

    • use context.webAPI.updateRecord() to update your record from inside your typescript, or
    • pass the updated value back up your canvas app in an Output or Bound parameter.

    The first option is the quickest and easiest to implement, but if you need that new, updated value immediately back in your canvas app, then it will disappoint. that webapi.updaterecord approach will update the value in the database, but it won't inform your canvas app.

     

    The second option requires that you take steps in both the PCF and in your Canvas app (return the value, then write a Patch with that new value) but it gives you immediate results in the canvas app, so it is often the better approach for user experience.

     

     

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @camer314 , 

     

    To the answer from @cchannon , I would add:

     - in the docs link that you posted, we can see that this feature is available for model-driven apps. For Canvas Apps is't "experimental" for now

     - I've succeded to change and save a boolean also in a Canvas App, but the dataset source for my PCF was a Excel Connctor, not a collection build inside my app. Maybe that's the difference.

    - Not sure if it had to do with the Excel connector, but to make it work I had to set the value on "{Id: !currentValue}", where I think the currentValue was a boolean.

     

    Maybe it helps. But since it's experimental, it's best to wait with production apps until GA.

     

  • camer314 Profile Picture
    173 on at

    Thanks @DianaBirkelbach and @cchannon ,

     

    I had already done the second approach of sending an event back to the app and then patching the collection. I was hoping there would be a more contained approach which is what this offered. One can dream 🙂

  • camer314 Profile Picture
    173 on at

    @DianaBirkelbach 

     

    I discovered that these functions do indeed exist. You just have to use the column name when setting a value as opposed to the display name, which is what I was using. Also those functions are async which I did not realise.

     

    After some modifications I was able to get this to flow with a data table (that is, make the changes and save and the changes are committed and broadcast). However that is not the case for a collection as your data source, it correctly saves and bounces back however it seems not to be reflected elsewhere in the app, including the collection itself.

     

    But possibly by the time it gets out of experimental it will correctly work for collections as well as tables.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 545 Most Valuable Professional

#2
Haque Profile Picture

Haque 314

#3
Kalathiya Profile Picture

Kalathiya 234 Super User 2026 Season 1

Last 30 days Overall leaderboard