cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RMC-Pro
Helper II
Helper II

Duplicating a Record in a CDS Custom Entity

Hello Community,

aksing for a hint.

 

I want to duplicate a Record in a Custom CDS Entity.

1) I have a DataTable Control on the Screen (i.e., one record is always selected).

2) I want to duplicate selected record with a command

 

 

Patch('Activities',Defaults('Activities'),DataTable.Selected)

 

 

, which doesn't work. => I assume because the command tries to copy also "System" fields which are not allowed to be changed.

 

I am assuming that, because if I try to duplicate a record with a slightly different command, i.e., with a list of the fields to be copied

 

 

Patch('Activities',Defaults('Activities'),{'Belongs To':DataTable.Selected.'Belongs To', ... (some other fields)})

 

 

, then command is executed as expected.

 

Is there a better way to duplicate existing record, i.e., without listing all the fields to be inluded into duplication? <= just to save some time with coding, I mean

 

Still learning!

 

Tnxs

br

@RMC-Pro

1 ACCEPTED SOLUTION

Accepted Solutions

It seems it can't be done without listing all the fields that have to be copied, leaving out those that are "system" fields (i.e., no write permition).

 

@RMC-Pro

View solution in original post

6 REPLIES 6
eka24
Super User
Super User

You can either switch to a Gallery and insert a button into the Gallery.

 

Also Onselect of the Datatable;

Set(CollectionName,ThisItem);
Patch('Activities',Defaults('Activities'),
{FirstName: CollectionName. FirstName,
ReceipientName: CollectionName.ReceipientName,
FullName: CollectionName.FullName,
EntryDate: CollectionName.EntryDate})

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Hi @RMC-Pro 

In a properly constructed relational database, I cannot think of a reason to duplicate a record unless you are moving it to another database. 

Hello @Drrickryp ,
creating a record, then changing a few fields (actually just a field or two).

 

<= would that make sense? Maybe I am using wrong approach, but can't think of better one.

 

Tnxs anyway.

br

@RMC-Pro

Hi @RMC-Pro 

If you are going to be designing Apps using PowerApps it would be in your best interest to learn the basics of relational database design.  I have a series starting with an overview to help you master the principles and apply them to PowerApps. https://powerusers.microsoft.com/t5/News-Announcements/Database-Design-Fundamentals-and-PowerApps-An... .  

Hi @Drrickryp,

like the series, very insightful, but doesn't give te answer to my question.

Thanks anyway.

 

Keep up the good work.

br

@RMC-Pro

It seems it can't be done without listing all the fields that have to be copied, leaving out those that are "system" fields (i.e., no write permition).

 

@RMC-Pro

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PWREduCon768x460.png

Join us at PWR EduCon - A Power Platform Conference

Learn from the top Power BI, Power Apps, Power Automate & Power Virtual Agents experts!

Top Solution Authors
Top Kudoed Authors
Users online (3,226)