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 / Trying to record chang...
Power Apps
Answered

Trying to record changes patched back to a list, in another list.

(0) ShareShare
ReportReport
Posted on by 13

Hello, and thanks for reading my post.

 

I have a power app that allows the editing of data in a SharePoint list. The fields include half a dozen choice and text input boxes. The person accessing the data is looked up in AAD, the users department is retrieved, and the data is filtered to the relevant departmental data which is presented to the user for editing. There is an edit and a save button that enables editing and then patches the data back to SharePoint, per line item. I am trying to record each and every change as a new line item in a second list to facilitate the next part of the required process I am trying to build. If there are multiple fields changed in a single line item of the first list, I would like to record each changed field as a new line item in the second 'audit' list. The audit list has columns like:

time/date, person making change, object being changed, value before change, value after change and then a bunch related to approvals and action.

 

Looking for any input on how to best do this, thank you!

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Jim_4469786f6e ,

     

    Could you tell me:

    • What controls and functions do you want to use to submit records?

     

    I assume:

    1. You use a button control to submit the record.
    2. To facilitate testing, I have 3 columns, they are ‘Title’ column , ‘TestA’ column and ‘TestB’ column. ‘Title’ column is the object . ‘TestA’ and ‘TestB’ are proprties of this object.

     

    If the above assumptions are true, I've made a test for your reference:

    1\ This is my list ‘LIST73’ . ‘TestA’ is a Single line of text column. ‘TestB’ is a choice column.(These columns are used to simulate your AAD data.)

    v-xiaochen-msft_0-1613454464915.png

     

     

    2\ This is my list ‘LIST74’.  'User' , 'Before' and 'After' are  Single line of text columns. 'Date and Time' is a date and time column. The list is used to store historical records.

    v-xiaochen-msft_1-1613454464918.png

     

     

    3\ Add a gallery control ‘Gallery2’ and set its Items property to:

    LIST73

     

    4\ Add a dropdown control ‘Dropdown1’ and set its items property to:

    Choices(LIST73.TestB)

     

    Set the default property of ‘Dropdown1’ to:

    Gallery2.Selected.TestB.Value

     

    5\ Add a textinput control ‘TextInput1’ and set its default property to:

    Gallery2.Selected.TestA

     

    6\ Add a button control and set its onselect property to:

    Clear(TestCollection);
    If(TextInput1.Text<>Gallery2.Selected.TestA||Dropdown1.Selected.Value<>Gallery2.Selected.TestB.Value,
    Patch(LIST73,Gallery2.Selected,{TestA:TextInput1.Text,TestB:Dropdown1.Selected}));
    If(TextInput1.Text<>Gallery2.Selected.TestA,
    Collect(TestCollection,{Item:Gallery2.Selected.Title,TestBefore:Gallery2.Selected.TestA,TestAfter:TextInput1.Text}));
    If(Dropdown1.Selected.Value<>Gallery2.Selected.TestB.Value,
    Collect(TestCollection,{Item:Gallery2.Selected.Title,TestBefore:Gallery2.Selected.TestB.Value,TestAfter:Dropdown1.Selected.Value}));
    ForAll(TestCollection,
    Patch(LIST74,Defaults(LIST74),{Title:Item,'Date and Time':Now(),User:User().Email,Before:TestBefore,After:TestAfter}))

     

    7\ The result is as follows:

    AAA.gif

    v-xiaochen-msft_2-1613454796410.png

     

    v-xiaochen-msft_3-1613454845543.png

     

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • Verified answer
    Jim_4469786f6e Profile Picture
    13 on at

    Hi Wearsky,

    Thanks for your detailed answer and the time that went into it. I am just using a 'save' button to execute the patch command by setting its onselect properties, your sample is directly applicable. And I am only using text input and choice fields, this also suites that fine. I am in process trying this out and will respond soonest!

    Regards,

    Jim

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
WarrenBelz Profile Picture

WarrenBelz 427 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard