Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
Unanswered

Patch specific record CDS

(0) ShareShare
ReportReport
Posted on by 2

Hi,

 

I'd like to use Patch to modify a specific record in a CDS table, i use the below syntax to create a new record:

 

Patch('CDS Table',Defaults('CDS Table'),
         {CDSColumn1: TextInput.text,CDSColumn2:DatePicker1.SelectedDate})

What syntax should be used to patch a specific record in that CDS table? (i have the CDS record ID for that specific record)

 

Thanks!

Categories:
  • mike528 Profile Picture
    236 on at
    Re: Patch specific record CDS

    If you have the source of the gallery items connected to a CDS entity or entioty view, for the record reference, you can simply use Gallery1.Selected or ThisItem depending upon where you put the patch command.

     

    For example, if you want to save the record using a button within the gallery item, you can use Patch(Entity, ThisItem, {Field: Value}). 

     

    If you use a radio button with set the Items to Choices(Entity.Field), then in your patch command simply use {Field: Radio1.Selected.Value}.

     

    Hope this helps.

  • Community Power Platform Member Profile Picture
    on at
    Re: Patch specific record CDS

    Hi

    I have the same issue, I have a gallery that I want to patch a value back into CDS from the powerapp and update a field in Dynamics 365. I have a Option Set in Dynamics with a Radio control in my canvas app. I want to change the radio1 control in the same gallery. 

     

     
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at
    Re: Patch specific record CDS

    Hi @PytByt 

    Your formula 

    Patch('SMU_Service Line', LookUp('SMU_Service Line', cr1e4_key = LabelKeyRejectedInspection.Text),
    {cr1e4_responds: RadioRespondsRejectectedInspection.Selected.Value,
    cr1e4_respondtext: TextInputQuestionRejectedInspection.Text,
    cr1e4_remarks: TextInputRemarksRejectedInspection.Text});

    References the labels in your gallery rather than the actual value of the item.  When I use Patch(), I always refer to the actual item to prevent disambiguation.  For example, 

    Patch(datasource,
    Lookup(datasource, ID = Gallery1.Selected.ID),
    {Fieldname1: TextInputx.Value, Fieldname2: Dropdownx.Selected.Value, Fieldname3: Radiox.Selected.Value})

    In your example, if you are using an icon inside of the gallery to submit the patch, you can use ThisItem instead of a Lookup() 

  • PytByt Profile Picture
    943 on at
    Re: Patch specific record CDS

    Hi @Drrickryp 

    I'm using thi formula to update my existing records in CDS, but no luck.

    The formula doesnt seems work at all for patching new or update the existing record.

    Patch('SMU_Service Line', LookUp('SMU_Service Line', cr1e4_key = LabelKeyRejectedInspection.Text),
    {cr1e4_responds: RadioRespondsRejectectedInspection.Selected.Value,
    cr1e4_respondtext: TextInputQuestionRejectedInspection.Text,
    cr1e4_remarks: TextInputRemarksRejectedInspection.Text});

    I'm trying to patch an update to an existing record in my cds trough my gallery items here:
    patch existing cds 1.png

    When i use ForAll function along with the formula above, it has delegation warning:
    patch existing cds 2.png

     

    ForAll(GalleryRejectedInspectionChecklist.AllItems, Patch('SMU_ Service Lines', LookUp('SMU_ Service Lines', cr807_key = LabelKeyRejectedInspection.Text),
    {cr807_responds: RadioRespondsRejectectedInspection.Selected.Value,
    cr807_respondtext: TextInputQuestionRejectedInspection.Text,
    cr807_remarks: TextInputRemarksRejectedInspection.Text}));

    Please Help,

     

    Thanks.

    Pytbyt

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at
    Re: Patch specific record CDS

    Hi @PytByt 

    You have an error in the second element of your Patch() function if you want to patch a record in your entity.  

    Patch('CDS Table',Defaults('CDS Table'),
     {CDSColumn1: TextInput.text,
     CDSColumn2: DatePicker1.SelectedDate})

     Defaults(datasource) is only used for adding a new record.  To patch an already existing record you need to specify it.  For example, if you want to patch a record in a gallery, you would use something like:

    Patch('CDS Table',Lookup('CDS Table', ID=Gallery1.Selected.ID),
     {CDSColumn1: TextInput.text,
     CDSColumn2: DatePicker1.SelectedDate})

    To specify the record being patched.  Refer to  https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

  • PytByt Profile Picture
    943 on at
    Re: Patch specific record CDS

    Hi @RaninHa 

    Have you solved the problem?

    If yes, how you solved it? 

     

    Can i have the patch formula you used to solved the problem please?

    Thanks,

    BR.
    Pytbyt

  • RaninHa Profile Picture
    2 on at
    Re: Patch specific record CDS

    Correction: 

    Patch('CDS Table',Defaults('CDS Table'),

             {CDSColumn1: TextInput.text,
              CDSColumn2: D
    atePicker1.SelectedDate})

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 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…

Leaderboard > Power Apps - Microsoft Dataverse

#1
mmbr1606 Profile Picture

mmbr1606 22 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 17

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 15 Super User 2025 Season 1

Overall leaderboard

Featured topics