Skip to main content

Notifications

Community site session details

Community site session details

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

patching CDS record in a variable doesn't work

(0) ShareShare
ReportReport
Posted on by 502

I have a record that I read from CDS which I put into a local variable. I can't seem to update that local variable. Creating just a simple record and patching that works fine, but for some reason when I get a record from CDS I can't patch it locally. I do NOT want to patch the record in CDS, I'm just trying to patch the local copy of the record. Any suggestions?

 

// this doesn't work, 'Program Code' is not updated
UpdateContext({Program: First(MAG_MDM_Programs) });
UpdateContext({Program: Patch(Program,{'Program Code': "Test Program Code"})});
// this works, count is updated
UpdateContext({record: { name: "Hello", count: 0 }});
UpdateContext({record:Patch(record, {count: record.count + 1})});

  • dave-jorgensen Profile Picture
    502 on at
    Re: patching CDS record in a variable doesn't work

    Even that actually isn't consistent, doesn't work all the time. So I guess that brings me around to the original problem, which is how to patch a local record that came from CDS

  • dave-jorgensen Profile Picture
    502 on at
    Re: patching CDS record in a variable doesn't work

    Wow. I think powerapps is a little buggy here. eventually figured out, that if I patch using the internal field name it works, but using the display name doesn't work.

    IE this works:

    UpdateContext({Test: First(MAG_MDM_Programs) });
    UpdateContext({Test: Patch(Test,{cr6e6_programcode: "Test Program Code"})});

     

    and this doesn't work:

     

    UpdateContext({Test: First(MAG_MDM_Programs) });
    UpdateContext({Test: Patch(Test,{'Program Code': "Test Program Code"})});

     

    Is this a known bug with Patch?

  • dave-jorgensen Profile Picture
    502 on at
    Re: patching CDS record in a variable doesn't work

    and further information, choosing a different CDS entity, I can patch that locally fine. IE this works:

    UpdateContext({Test: First(MAG_MDM_Traxes) });
    UpdateContext({Test: Patch(Test,{cr6e6_adjustmentvaluescore: 567})});

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 87 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

Overall leaderboard