Making duplicates or copies of records is a recurring need

Making duplicates or copies of records is a recurring need

Introduction:

Welcome to our comprehensive guide on how to ‘Duplicate Records PowerApps’ seamlessly. Whether you’re working with individual records, gallery items, or user-specific data, PowerApps provides the tools you need to make copies efficiently. In this tutorial, we delve into the methods that allow for quick and easy duplication within your data-driven applications. Should you encounter any hurdles, our expert assistance is just a query away, don’t hesitate to contact us for expert assistance.

Making a Duplicate of a Record from a Form

Begin with an existing edit screen that hosts an edit form. To allow duplication, incorporate a button which, when clicked, clones the form data into a fresh record.

Steps:

  1. Add a button to the form.
  2. Assign the following formula to the button’s OnSelect property:
    Patch(DatabaseName, Defaults(DatabaseName), EditScreen1.Updates)

Note: This formula uses the patch function, requiring three arguments – the data source (DatabaseName), a new record (using the Defaults function), and the fields to be updated (sourced from the form’s Updates property).

Cloning a Record from a Gallery Control

Another efficient way to replicate a record is directly from a gallery screen.

Steps:

  1. Integrate a button into the gallery item template.
  2. For the OnSelect property of the button, use the formula:
    Patch(DatabaseName, Defaults(DatabaseName), 
    { Field1:ThisItem.Field1 & "(Copy)",
    Field2:ThisItem.Field2, Field3:ThisItem.Field3 })

This approach uses the patch function. The formula generates a new record, with the existing record from the gallery used as a reference. A “(Copy)” suffix is added to differentiate the duplicate record.

Duplicating the Most Recent Record

PowerApps allows users to effortlessly clone the most recently created record with the help of a button.

Steps:

  1. Integrate a button into the desired screen.
  2. Use this formula for the button’s OnSelect property:
    With( { latestEntry: First( FirstN( 
    SortByColumns(DatabaseName, "RecordID", Descending), 1 ) },
    Patch(DatabaseName, Defaults(DatabaseName), { Field1:latestEntry.Field1 & "(Copy)",
    Field2:latestEntry.Field2, Field3:latestEntry.Field3 }))

Duplicating the Last Record Created by a Specific User

To create a duplicate of a record authored by a specific individual, apply the following:

Steps:

  1. Use this formula:
    With( 
    {latestUserEntry: First( FirstN(
    SortByColumns(
    Filter(DatabaseName, 'Created By'.Email = "[email protected]"), "RecordID", Descending ), 1 ) },
    Patch(DatabaseName, Defaults(DatabaseName),
    { Field1:latestUserEntry.Field1 & "(Copy)",
    Field2:latestUserEntry.Field2,
    Field3:latestUserEntry.Field3 })
    )

Reference:

Conclusion:

Duplicating records in PowerApps, whether from a form, gallery or based on user criteria, can be accomplished efficiently with the techniques described above. This guide aimed to provide a comprehensive look into the various methods of creating record duplicates. Should you have any technical questions or need further assistance, feel free to reach out to us. We’re here to help and guide you towards success.

About The Author