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!
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.
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.
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()
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:
When i use ForAll function along with the formula above, it has delegation warning:
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
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
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
Correction:
Patch('CDS Table',Defaults('CDS Table'),
{CDSColumn1: TextInput.text,
CDSColumn2: DatePicker1.SelectedDate})
mmbr1606
22
Super User 2025 Season 1
stampcoin
17
Michael E. Gernaey
15
Super User 2025 Season 1