Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Answered

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);
 }

 

 

 

  • Verified answer
    KASCHN Profile Picture
    293 on at
    Re: Dataset PCF for Canvas App - error on record.save()

    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. 

  • KASCHN Profile Picture
    293 on at
    Re: Dataset PCF for Canvas App - error on record.save()

    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. 

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at
    Re: Dataset PCF for Canvas App - error on record.save()

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

     

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 85 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 55 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 52 Super User 2025 Season 1

Overall leaderboard