web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dataset PCF for Canvas...
Power Apps
Unanswered

Dataset PCF for Canvas App - error on record.save()

(0) ShareShare
ReportReport
Posted on by 293

I have a PCF with a dataset configured for a canvas app. I am trying to update the records in the dataset using record.setValue() followed by record.save(). After record.setValue() executes I have confirmed that my record.isDirty() == true. When I proceed to record.save(), I get an error. Has anyone been able to successfully execute record.save() in a canvas app or do you know what this error is?

 

TypeError: Cannot read properties of undefined (reading 'patchAsync')
 at e.<anonymous> (pa.core.bundle1.js:11:317880)
 at pa.core.bundle3.js:69:460357
 at Object.next (pa.core.bundle3.js:69:460463)
 at pa.core.bundle3.js:69:459397
 at new c.Class.derive._oncancel (base.js:2:44584)
 at new e (pa.core.bundle3.js:69:600665)
 at l (pa.core.bundle3.js:69:459171)
 at e.@pa-client/appmagic-runtime-app.e.save (pa.core.bundle1.js:11:317690)
 at ResultItemVM.eval (ResultItemVM.ts:159:22)
 at Generator.next (<anonymous>)

 

 

 

 

My code is as follows:

 

 

 

 

async onChange( newValue: string | null) {

 const vm = this.serviceProvider.get<CanvasWorksheetVM>(CanvasWorksheetVM.serviceProviderName);
 const context = this.serviceProvider.get<ControlContextService>(ControlContextService.serviceProviderName);
 const id = this.record.getRecordId();
 const jsonObj: { id: string, textValue?: string | null, numberValue?: number | null } = { id: this.id };
 let numValue : number | null = null;
 const record = context.getDataset().records[id]
 switch(this.fxnlDataType){
 case "string":
 jsonObj.textValue = newValue ? newValue as string : null
 this.textValue = newValue ? newValue as string : null
 try {
 //@ts-ignore
 await record.setValue("TextValue", newValue).then(()=>console.log({dirty : 
 record.isDirty()}));
 } catch(e){
 console.error(e as Error);
 }
 break;
 }
 try {
 //@ts-ignore
 await record.save()
 } catch(e){
 console.error(e as Error)
 }
 vm.sampleProperty = JSON.stringify(jsonObj);
 }

 

 

 

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

    Hi @KASCHN , 

     

    Haven't done it inside a Canvas App, but I did it inside a CustomPage bound to something else that Dataverse.

    It could be a Canvas App issue. But maybe it depends on the Datasource type you are using.

    The Dataset inside the Canvas Apps PCFs have a method "getDataSetCapabilities", where you can check if your datasource "isEditable", "isSortable", "canCreateNewRecords" and so on: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/dataset/getdatasetcapabilities?WT.mc_id=BA-MVP-5004107

    Maybe it helps to get closer to the reason behind the error message...?

     

  • KASCHN Profile Picture
    293 on at

    Thank you Diana, I should have mentioned that the datasource is actually a customized collection that I passed from the canvas app. Perhaps save() doesn't have a concept of how to update to a collection. However, I am going to try it on a custom page which is my final destination in any case. 

  • Verified answer
    KASCHN Profile Picture
    293 on at

    After having done some testing the issue really is that I was passing the dataset a customized collection from my canvas app. The record.save() is trying to save the changes to the database hence it could not. I think, as @DianaBirkelbach has mentioned elsewhere, I will need to use an output property and the on change event from my canvas app to update the record manually. 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard