cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mwilliamsf
Level: Powered On

Add data to a second ongoing historical list

I have a sharepoint list as the data connection for my powerapp.  It works as it should, updating numbers, text and dates to the list when edited from the app.  What I would like to do is create another list to use as a historical view.  When updating list1, add the updated data to list2 but NOT REPLACE DATA. .

1 ACCEPTED SOLUTION

Accepted Solutions
mwilliamsf
Level: Powered On

Re: Add data to a second ongoing historical list

Instead of using the patch function with OnSuccess in the powerapp, I used a Sharepoint Flow custom action with my inventory list. Whenever an item is modified in the inventory list,  the flow writes the modified info to the historical list so that we can track inventory purchases.

 

Thank you for the input.

 

Mark Williams

8 REPLIES 8
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Add data to a second ongoing historical list

You can certainly do that; if you're using a form, you can save the current item into a different list. One place you can do that is on the OnSuccess property of the edit form. For example, if you have a list MyList with columns 'Title', 'Value', and you want to save all changes into a list called MyListHistory, with similar columns, plus the time for the change and who made the change. You can have this expression on the OnSuccess property of the form:

Patch(
    MyListHistory,
    Defaults(MyListHistory),
    {
        Title: Title_DataCard2.Update,
        Value: Value_DataCard2.Update,
        Timestamp: Now(),
        UpdatedBy: User().Email
    });
Back()

A Patch call with the Defaults for the list for the second parameter will cause a new item to be added to that list.

mwilliamsf
Level: Powered On

Re: Add data to a second ongoing historical list

Thank you for your reply.  Is it necessary to add a second edit form or can I use the onselect with the original form?

mwilliamsf
Level: Powered On

Re: Add data to a second ongoing historical list

I meant to say OnSuccess.

mwilliamsf
Level: Powered On

Re: Add data to a second ongoing historical list

My destination is OrderHistory list.  Columns are Item, Ordered,Date and Vendor.

Patch_OrderHistory.png

 

mwilliamsf
Level: Powered On

Re: Add data to a second ongoing historical list

From the screen capture on the previous post, I can't figure out what the correct formula should be.  Anything anyone can add is greatly appreciated.

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Add data to a second ongoing historical list


@mwilliamsf wrote:

Thank you for your reply. Is it necessary to add a second edit form or can I use the onselect with the original form?


You don't need a second form; the Patch function can access the data source directly.


@mwilliamsf wrote:

From the screen capture on the previous post, I can't figure out what the correct formula should be.  Anything anyone can add is greatly appreciated.


 Try hovering the mouse on the parameters of the Patch call; a tooltip should appear with more information about the error.

mwilliamsf
Level: Powered On

Re: Add data to a second ongoing historical list

Instead of using the patch function with OnSuccess in the powerapp, I used a Sharepoint Flow custom action with my inventory list. Whenever an item is modified in the inventory list,  the flow writes the modified info to the historical list so that we can track inventory purchases.

 

Thank you for the input.

 

Mark Williams

reddyapps
Level: Powered On

Re: Add data to a second ongoing historical list

@CarlosFigueira  hi, i have a similar requirement....im using sql table as source.  

when i update a field like status or any other field, it should insert a new record in that table evry time we update with updatetime, updateby. how can i do this?