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 Apps
Answered

Archive Records

(0) ShareShare
ReportReport
Posted on by 147

Hi,

 

I am trying to implement a function into my app, where usually the delete button will remove a record from the source data (as in if you were looking at a gallery of records, and had selected one to view in more detail - current delete button formula: Remove(Beds, BrowseGallery1.Selected)), i instead want this record to be transferred over to an identical 'archive table' where old records can go, so that they are no longer visible in the gallery, but the record is not actually deleted.

 

I can't find any formulas that seem to be able to do this.

 

Thanks

Categories:
  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    To solve your issue, your code in ON SELECT property of the REMOVE button looks like this:

     

    Collect('archive table', BrowseGallery1.Selected);

    Remove(Beds, BrowseGallery1.Selected))

    (if the archive table is actually a local collection)

    OR 

    Patch('archive table', Defaults('archive table'),BrowseGallery1.Selected);

    Remove(Beds, BrowseGallery1.Selected))

    (if you want to write directly on database).

  • rebeccas Profile Picture
    2,591 on at

    I typically do this in Flow (PowerAutomate). In the app I have the button change the status to "Archive" and then I have a Flow that looks for when that item is modified and the status is "Archive" create a new item (on the archive list) and delete the item (from my active list). You could also do this in PowerApps if you use Patch to first create a new item (on new archive list), then remove item from current list. 

     

    Also, I would keep in mind -- when I do an Archive list I carry over a few other columns so I don't loose it like CreatedBy and Created

  • eka24 Profile Picture
    20,925 on at

    Try combining, Remove, Collect and Patch

     

    Remove and Collect:

    On the OnSelect of the Icon / Button to Select the Gallery;

         Collect(DeletedCollection,ThisItem);

             Remove(DataSource,LookUp(DataSource,ID = ThisItem.ID))

     

    The ID in this case could be replaced with any Unique Column

    This Creates a collection called DeletedCollection on all items Deleted

     

    Patch the Collection DeletedCollection To the New DataSource:

    OnSelect of a Buttton:
           ForAll(DeletedCollection,Patch(ArchiveDatasource, Defaults(ArchiveDatasource),   

            {Column1: DelecteCollectionColumn1, Column1: DelecteCollectionColumn2,
             Column1: DelecteCollectionColumn3}) )

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

    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.

  • atray13 Profile Picture
    147 on at

    Hi thanks for the response. I have tried the patch formula but it doesn't copy the record over to the other table. I am getting the error message: _PowerAppsId_: The specified column is generated by the server and can't be specified.

  • rebeccas Profile Picture
    2,591 on at

    Did you try and Patch the ID field?

     

    Usually that error means you are trying to create a filed (via Patch) that is being created by your SharePoint list. Like the ID column or one that is calculated on your SharePoint list. 

  • atray13 Profile Picture
    147 on at

    Hi thanks for the reply.

     

    I have tried this and it seemed ok until the last bit, i couldn't get the formula to accept the   {Column1: DelecteCollectionColumn1, Column1: DelecteCollectionColumn2,
             Column1: DelecteCollectionColumn3}) ) 

     

    part. It wasn't suggesting anything similar where it usually suggests what to put in, and couldn't quite figure out what it is that has to go here?

  • atray13 Profile Picture
    147 on at

    No i just tried to patch the whole record i think. I haven't used patch before so not too familiar with it. My formula looks like this:

    Patch(Archive, Defaults(Archive), BrowseGallery1.Selected)

     

    I was going to try out your suggestion of Power Automate once i get granted access by my IT department.

  • Verified answer
    rebeccas Profile Picture
    2,591 on at

    So you can't Patch a like the second you put where it refers to gallery. To use patch you have to refer to each column. Here is how it lays out:

     

    If New Record:

     

    Patch(SPList, Defaults(SPList), {Title: TextInput1.Text, Column2:TextInput2.Text})

    * This is if the columns are single line text fields...different if other types..let me know if so and what type.

     

    Edit Record: 

     

    Patch(SPList, LookUp(SPList, ID=Gallery1.Selected.ID), {Title: TextInput1.Text, Column2:TextInput2.Text})

     

    You don't have to use all columns for the New or Edit...just the ones you want. If it is New you must use the Title field because it always required. 

     

    Let me know if this helps and what else you need to go forward from there.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard