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 / Use patch to duplicate...
Power Apps
Unanswered

Use patch to duplicate a record dynamically

(0) ShareShare
ReportReport
Posted on by 29

Hi all,

 

I want to use the Patch function to copy a sharepoint list record.  The list contains many columns (50+) so I do not want to write out each column name/value pair manually--I want it to get the values dynamically from a "RecordToCopy" record. I also do not want to use Power Automate for the same reason (in the Create Item connector I would have to indicate the value of each column).

 

2022-06-21 10_07_28-Power Apps — Mozilla Firefox.png

 

The above commands only result in a new liste item being created, with no values from the RecordToCopy copying over to NewRecord.

Categories:
I have the same question (0)
  • theapurva Profile Picture
    970 Super User 2024 Season 1 on at

    Hello,
    This is not working because when you are submitting the record, you are pushing read only columns also.
    so you will have to drop the columns.

    If you hover over your formula it will show the readonly fields which you are pushing so drop them and then Patch.

    Below is Sample formula where I am dropping the read-only columns of my list.

    Set(RecordToCopy,First(DropColumns(Filter(TeamDetails,ID=1),"ID","Modified")));
    Set(NewRecord,Patch(TeamDetails,Defaults(TeamDetails)));
    Patch(TeamDetails,NewRecord,RecordToCopy)

     

    you can see the read only field causing the error by hovering over the formula:

    theapurva_0-1655829237689.png

     

     

  • mnoah Profile Picture
    29 on at

    @theapurvathank you.  This is a step in the right direction.  Looks like I will need to figure out all of the read-only fields.  So far I am up to "ID","Modified","{FullPath}", "{Identifier}"

  • mnoah Profile Picture
    29 on at

    @theapurvaI am stuck.  It is saying that "ResQuarterlyIntroID#Id" is read-only. But when I try to drop that column it says it does not exist.  "ResQuarterlyIntroID" I have dropped. (it is a lookup to another SP list).

     

    Edit: it seems the lookup column is the issue.

     

     

    2022-06-21 13_40_15-Power Apps — Mozilla Firefox.png

  • theapurva Profile Picture
    970 Super User 2024 Season 1 on at

    hello @mnoah ,

    Another workaround is like below:

    Add a Gallery of that list then perform below

    1. Add one Button say duplicate and edit and onselect of it redirect to editform

    2. put edit form Item property as Gallery.Selected

    3. Add a button named 'Save'.

    4. Add below function to OnSelect of Save.

     

    Patch(YourListName,Defaults(YourListName),YourEditForm.Updates)

     

    This will create the new record in your list. 

    this will save a lot of your effort I believe.

     


    Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!

     

     
  • mnoah Profile Picture
    29 on at

    Hi @theapurva 

     

    Thank you for the help.  But I am trying to do this "programmatically" and not with the help of an edit form.  I have 7 different SP lists.  They are all "connected" by an ID from a parent list.  User clicks a "Copy all records" button and I want a new record inserted into each list as a duplicate.  Perhaps a SP List was not the right tool for this job...

  • theapurva Profile Picture
    970 Super User 2024 Season 1 on at

    Hello Could you confirm me about how are you looking UI?
    If its like
    there will be gallery and button 'Copy' on each record?

    this button will copy item to other 7lists.

    Is it like this?

  • mnoah Profile Picture
    29 on at

    No, I am only using a gallery for parent list (which just contains meta-data).  The main screen allows user to choose a parent record, and then I have 7 different screens with EditForms that all pull in data from the parent record.

     

    I think what I am going to have to do is have one screen with all of the edit forms, and a "Copy records" button that loops through each section and patches with the form.updates method.

     

    2022-06-21 15_57_47-.png

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