cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Capture SharePoint List Item Changes Like Version History Details Page

I'm working with a list that has 30+ fields and I need to capture what fields have been updated and output it to another list or table.  Using the Get changes for an item action, is it possible to output only the fields that have changed and their value?

My first thought was to loop on or filter the output of the Get changes action, then somehow get the associated field values.

22 REPLIES 22

The Get Changes for an item or file action that can be used to determine which column has changed.

There is a Has Column Changed dynamic content that returns true if the field was changed or false if the field did not change.

ekarim2020_1-1630013012585.png

 

ekarim2020_0-1630012845271.png

Ellis

Right, but retrieving the field values is what I'm looking for.  


"Using the Get changes for an item action, is it possible to output only the fields that have changed and their value?"

My hope is to avoid creating a large condition or switch statement.

This is possible and I can offer an approach to the problem - though other contributors with more experience than I should be able offer something better and more refined. But the following should get you started.

If we start with a simple SharePoint list called Routing - I want to know when any of the column values are changed; I want to receive an email showing me a list of the the columns that were changed along with their new values:

ekarim2020_0-1630068600470.png

If you have versioning enabled on the list, you can view an item's version history and see which columns were changed and what the new values are:

ekarim2020_3-1630071328161.png

The version history can be accessed by right clicking an item and then selecting Version history.

ekarim2020_2-1630070870416.png

If we could get access this version history via Power Automate, and access to just that subset of data as shown in the version history then our job is done and we will have what we need. But I haven't found a way to do this or it is likely that this is not currently possible with Power Automate?

For now I will have to try to do this manually, and I will post a possible approach to the issue in the next post.

See also: Get the changes made to SharePoint Items with Power Automate

Ellis

Here is a demo flow along with some description of how it works. If you are able to get it to work, you can refine and merge a number of steps. Unfortunately it looks more complicated than it really is. The flow could work with almost any list.

ekarim2020_0-1630098139666.png

If we start with a simple SharePoint list called Routing - I want to know when any of the column values are changed; I want to receive an email showing me a list of the the columns that were changed along with their new values. In the example below, the Folder and Preference column have been changed for item ID 14 and I receive an email with the changes that were made:

ekarim2020_1-1630098238817.png

What I am trying to do is create an array that stores the SharePoint column names and a true/false value indicating if that column was changed or not. The array can be iterated over i.e. accessing each element of the array one by one. The array could be a JSON array but for simplicity I am going to use an array of strings:

ekarim2020_21-1630102496136.png

Here is the high-level view of the flow:

ekarim2020_2-1630098409205.png

Part 1: The trigger and get changes action:

ekarim2020_3-1630098458558.png

Initialise an array variable varListOfColumnsChanged - which will store the SharePoint column names and whether the columns were changed or not (true or false):

ekarim2020_6-1630099004810.png

We can get a list of all the columns and their changed states from the action Get changes for an item or a file (properties only). This data is given to us as a JSON object from the dynamic content ColumnHasChanged. I convert ColumnHasChanged to a string and store it in varStringData.

ekarim2020_12-1630100566440.png

Split varStringData string at the comma delimiter ',' - creating an array as you see above, in the Compose Split String at comma action.

 

outputs('Get_changes_for_an_item_or_a_file_(properties_only)')?['body/ColumnHasChanged']
outputs('ColumnHasChanged_as_JSON_Object_Data')
split(variables('varStringData'),',')

 

Part 2:  After the split action we need  to clean up the column names in the array by removing escaped strings (eg. " double-quotes got replaced with  \"  when the JSON object was converted to string) as well as removing other unwanted characters such as the '{' and '}' characters. The high level view of this section is shown below:

ekarim2020_8-1630099402261.png

ekarim2020_0-1630105727320.png

The escaped strings \" are removed along with { and } characters as you see above in the green box.

 

replace(items('Apply_to_each'),'"','')
replace(replace(outputs('Sanitise_Item_Step_1'),'{',''),'}','')

 

A little more tidy up to separate the SharePoint column name and its change state value using split:

ekarim2020_11-1630100001151.png

The split expression is:

 

split(outputs('Sanitise_Item_Step_2'),':')

 

The expression for Append to array variable varListOfColumnsChanged is:

 

first(outputs('Compose_Split_on_Colon'))
last(outputs('Compose_Split_on_Colon')

 

Note the colon between the two expressions:

ekarim2020_14-1630100930176.png

Part 3: Finally we check the SharePoint column name (key) and its change state value, and if it was changed, we store this column name in a variable - which I will use to email a list of all the changed columns. The high level view of this section is shown below:

ekarim2020_15-1630100995267.png

ekarim2020_16-1630101039830.png

 

ekarim2020_0-1630107097764.png

Example of the output that was generated:

ekarim2020_20-1630101561753.png

The flow could work with almost any list, you would just need to change the List/Library names. In the example below I connected the flow to an Issue tracker SharePoint list:

ekarim2020_22-1630104348957.png

ekarim2020_23-1630104364264.png

I get the following results, though you will need to handle the the values in complex columns:

ekarim2020_24-1630104488645.png

Hope this helps.

Ellis

 

outstanding post!   thank you for taking the time to write all of this up.

I was able to finally refactor the flow to fewer steps. This makes the flow shorter and easier to understand. All credit to Identify which SharePoint item columns were updated in Power Automate by Tom Riha. 

ekarim2020_0-1630145740775.png

(1)  Add the trigger and Get changes actions:

ekarim2020_1-1630146040993.png

(2) Initialise a string variable for the email body:

ekarim2020_2-1630146203119.png

(3) Convert the object HasColumnChanged to string, and split at the comma delimiter. We filter only the items that contain string ':true'

ekarim2020_3-1630146271847.png

 

From:
split(string(outputs('Get_changes_for_an_item_or_a_file_(properties_only)')?['body/ColumnHasChanged']),',')

item()
contains
string(':true')

 

Sample output:

ekarim2020_13-1630148732770.png

(3) Use json() to do all the clean-up! From "\"Title":true" to "Title" using json(item()):

ekarim2020_6-1630146742493.png

Sample output:

ekarim2020_14-1630148771934.png

(4) Constructs the email body containing the changed columns and their values:

ekarim2020_12-1630148562603.png

 

body('Select')
item(): triggerBody()[item()]

 

ekarim2020_9-1630147345659.png

Sample output:

ekarim2020_11-1630148233653.png

Ellis

While this works great, it fails when a field is empty

Hi @msabau ,

 

At what point in the flow does it fail? We may be able to adjust the expressions to handle missing values.

 

Ellis

Solved it by following the guide you linked above. The only problem is that that tutorial gets rid of the values. For the moment I don't need them, but if i'll ever need to know the values that were changed, I'll try to figure it out on my own

Basically this is the error:

 

InvalidTemplate. Unable to process template language expressions in action 'Append_to_string_variable_2' inputs at line '0' and column '0': 'The template language expression 'triggerBody()[item()]' cannot be evaluated because property 'Email' doesn't exist, available properties are 'Ottienielemento_ID'. Please see https://aka.ms/logicexpressions for usage details.'.

 

It happens when I try to use triggerbody to append the value of the field to the string.

Not really sure how to fix it at the moment.

 

EDIT: I guess this happens because my trigger is a button in a powerapp, not the same trigger as your guide. I'll try fix it now

Hi @msabau .

 

Here is something to try.  If you update the expression in question (step 4) to the following:

Old:     triggerBody()[item()]

Updated: triggerBody()?[item()]

 

when the property is not found, a null value (empty) should be returned, and the flow should continue. For more info, see How to query JSON data using JSON notation with Power Automate

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

Thank you for your reply. With the updated expression the flow doesn't stop, but it doesn't display values

 

Yes, because the expression triggerBody()?[item()] is evaluating to null or empty. This means that the property triggerBody()?['Email'] does not exist in the triggerBody().

 

Check your data for the correct property name. 

Example, triggerBody()?['Author']:

{
  "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
  "Claims": "i:0#.f|membership|ellis.karim@dev365.com",
  "DisplayName": "Ellis Karim",
  "Email": "ellis.karim@dev365.com",
  "Department": null,
  "JobTitle": "Business Manager"
}

triggerBody()?['Author/Email']: 

 ellis.karim@dev365.com


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

Thank you for your reply. I'm wondering if there is a way to cycle through all the properties so that I don't have to type them all manually

I finally figured it out. Thank you for your tremendous help

msabau
Advocate III
Advocate III

If anybody else has the same issue I had or just want to greatly simplify the flow, instead of Sanitising the JSON, you could just do this:

if(contains(string(triggerBody()?[item()]), 'Value'), triggerBody()?[item()]?['Value'], triggerBody()?[item()])
If an item comes from a multiple choice field, meaning that it contains the word "Value", then it only extracts said value, otherwise it just gets the regular value from regular fields. I used this in the stage just before composing the email and you basically get rid of all the sanitisation
SCoutier
Frequent Visitor

I recently had a very similar issue, and wanted to share a quick fix that I found: 

I have two nearly identical lists with very different purposes and contain product information. However my users are used to populating one of the lists and not the second. I need the first list to populate the second list with user changes, or keep the value from the second list. 

 

Trigger: When an item is created or modified - List 1

 

Get Changes for an item or file (properties only)

 

Get items - List 2: filter query - Product Sku (List 2) eq 'Product Sku' (List 1)

 

Apply to each (List 2 Value) (Update item - List 2)

 

in each column I used an if statement: if(equals(Has Column Changed: Product Description, 'true'), Product Description List-1, Product Description List-2).

Rinse and repeat for each of the columns that I need to have dynamically changed when a user updates a field.

 

SCoutier_0-1686578929352.png

 

Anonymous
Not applicable

Thnks for article and i’m following, it seems different UI between current one : there was only ‘Map’ text box but now it has ‘Key’ and ‘Value’ both. so to proceed next step, I couldn’t know how to input ‘json(item())’ in ‘Select’.

Can you guide me how to ?

 

osy78_0-1703769293890.png

 

Hi @Anonymous 

 

It seems that you have experimental features enabled for the Power Automate editor? Try turning the experimental features off as it will make following the solution much easier. See How to Turn on Experimental Features in Power Automate

To switch to text mode click the icon as shown below:

Snag_14d6ec5b.png


Ellis
____________________________________
If I have answered your question, please mark the post as ☑️ Solved.
If you like my response, please give it a Thumbs Up.
My Blog Site

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (752)