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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Duplicate a Record bas...
Power Apps
Answered

Duplicate a Record based on a column value

(0) ShareShare
ReportReport
Posted on by 4

I need to automatically duplicate a record on a table depending on the value of a column while using a patch function and I just can't figure out how to do it.

Case Scenario:

Gallery: Gallery_plan_attach

TitleSample IDRepetitionsProduct
Example 1ABC_1232Product A

I need to recreate the exact same record into the second table and create X number of duplications based on the Repetitions column.

It should look like this

Destination Table: MV_DATA_CAPTURES

TitleSample IDRepetitionsProductRepetition No
Example 1ABC_1232Product A1
Example 1ABC_1232Product A2

 

It copies it and adds sequence values into column Repetition Number based on the value of the Repetitions column.

This is what I have so far 'OnSelect' of a button:

Set(LoopTimes,CountRows(Gallery_plan_attach.AllItems));
ForAll(
    Sequence(LoopTimes,1,1),
    Patch(MV_DATA_CAPTURES, Defaults(MV_DATA_CAPTURES),
    {{Title: Title,
    Sample_ID: Sample_ID,
    Repetitions: Value(Repetitions),    
 Product: Product,
    'Replication No': Index(Gallery_plan_attach.AllItems)
}    )
)

 

Categories:
I have the same question (0)
  • Verified answer
    DJ_Jamba Profile Picture
    2,837 Moderator on at

    Hi @changorj 

     

    Might need a tweak because I'm not able to test in Power Apps, but try:

    ForAll(
     Sequence(Gallery_plan_attach.AllItemsCount),
     ForAll(
     Sequence(
     Value(Index(Gallery_plan_attach.AllItems,Value).Repetitions)
     ) as reps,
     Patch(MV_DATA_CAPTURES, Defaults(MV_DATA_CAPTURES),
     {
     Title: Index(Gallery_plan_attach.AllItems,Value).Title,
     Sample_ID: Index(Gallery_plan_attach.AllItems,Value).Sample_ID,
     Repetitions: Value(Index(Gallery_plan_attach.AllItems,Value).Repetitions), 
     Product: Index(Gallery_plan_attach.AllItems,Value).Product,
     'Replication No': reps.Value
     } 
     )
    )

     

  • changorj Profile Picture
    4 on at

    it worked! ! !

    Thank you so much! 

  • DJ_Jamba Profile Picture
    2,837 Moderator on at

    Awesome! Glad it’s solved!

    d(-_-)b

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard