web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Cloning records in a C...
Power Apps
Unanswered

Cloning records in a CDS entity

(0) ShareShare
ReportReport
Posted on by 704

I have a group of animals with numbers and one has got an event in an event table (like a vaccination).

All 40 animals of the group need the same vaccination but since that is a lot of work i want to copy the event (vaccination) to the other animals. The event record has many fields (columns) which may be more in the future so I definitely do not want to name them all anywhere in this code.

I get the animals (numbers) in a collection an do

 

 

If(
 Toggle1.Value And (CountRows(TargetDieren)>0)
 ;ForAll(TargetDieren
 ;If(Val>0;Patch(DierEvent;Defaults(DierEvent);SelectedDierEventRecord;{DocaDierId:Val}))
 ) 
)

 

Where TargetDieren is the collection, Val is the animal number field in that collection, SelectedDierEventRecord is the record to copy and DocaDierId the id field in the event table. Toggle1.value is just the state of a copy or move toggle.
Where this goes wrong is that the original record contains certain fields I may not write to because powerapps does that like versionnumber. How can I avoid this?

 

I have the same question (0)
  • v-siky-msft Profile Picture
    on at

    Hi @HansHeintz 

     

    How do you define the SelectedDierEventRecord?

    What is the error message?

    Do you mean some fields in SelectedDierEventRecord is not supported to write into CDS?

    If so, I suggest you first save the selected record into a collection instead of a variable by ClearCollect function and then use DropColumns function to remove some fields that can not be written.

    I assume that SelectedDierEventRecord has been changed to a collection, then try this code.

     

    If(
     Toggle1.Value And (CountRows(TargetDieren)>0)
     ;ForAll(TargetDieren
     ;If(Val>0;Patch(DierEvent;Defaults(DierEvent);First(DropColumns(SelectedDierEventRecord;"FieldName1";"FieldName2"));{DocaDierId:Val}))
     ) 
    )

     

     Hope this helps.

    Sik

  • HansHeintz Profile Picture
    704 on at

    The error I got
    versionnumber: De opgegeven kolom wordt gegenereerd door de server en kan niet worden opgegeven.

    Which translates into something like

    versionnumber: The entered column is generated by the server and cannot be entered

    Following your example seemed succesfull, dropping one "standard" column after another but at some point the error was
    {attachments} ID required
    Since I have no field "attachments" or "ID" I gave up and now created code naming all fields I requier and submit to the fact I have to review this code everytime my table changes.

  • v-siky-msft Profile Picture
    on at

    Hi @HansHeintz ,

     

    How do you define the SelectedDierEventRecord?

    Is it from the CDS entity or Sharepoint list?

    Sik

  • HansHeintz Profile Picture
    704 on at

    It is a CDS entity, I guess I mistyped that in the subject line.

     

    >>corrected

  • v-siky-msft Profile Picture
    on at

    Hi @HansHeintz ,

     

    So, have your issue been resolved?

    Sik

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard