cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Matren
Super User
Super User

Expression help to filter SharePoint Get changes for an item or file (properties only) since VersionLabel

Hello Power Community,

 

I would like to filter the SharePoint Get changes for an item or file (properties only) since the earliest version of a record. Usually I use "Since 1.0". However, I am currently storing 500 versions of a record in my SharePoint list, and there are some records that have over 500 changes. For example, one record has over 5000 versions and the Version Labels range from 4500 to 5000. Whenever I use "Since 1.0" with this record, the Power Automate flow will not function since there is no Version Label 1.0 that has been saved.

 

Is there an expression that I could use for the Since field that would generate the earliest version that has been saved? Perhaps I could leverage the "Min" or "First/Last" function?

 

I tried

min(outputs('Send_an_HTTP_request_to_SharePoint')?['body/value']?['versionlabel'])

but that did not work.

 

Thank you for your assistance.

 

Version Label Expression.png

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi David,

 

Using your recommendation, and tranforming it for this particular flow, yields:

 

formatDateTime(last(outputs('Send_an_HTTP_request_to_SharePoint')?['body/value'])?['Created'],'yyyy-MM-ddTHH:mm:ssZ')
 
 Running the flow, and looking at the output for "Get changes for an item or file (properties only)" function:
Matren_0-1659546679436.png

 

You'll note that the Since Version Number should be 4565.0 (the last version in the data); however, the function is changing it to 4566.0! We are storing 500 hundred versions so 5065-500 = 4565.

 

Also, Version Label 4565 is showing up in the data. This is underscored when I am not able to reference the last version label of 4565 in an expression for the "Since" field, because whenever I do, an error appears stating that Version Label 4565 can not be found (see previous screenshots posted to this thread). And yet, 4565 is outputed to the CSV table.

 

Matren_1-1659547493031.png

 

You'll note the 4565 and 4566 in the csv ouput have the SAME date time stamp. I've noted that some (but not all) of the date time stamps for the Versions repeat and I am unable to tell the difference in what changed for these versions.

 

By not referencing the earliest saved version, there is a risk that it won't correctly identify all the column changes.

 

 

 

View solution in original post

Matren
Super User
Super User

@David- @RezaDorrani 

 

In summary, I think there may be a data issue or perhaps a bug. I directly entered 4565.0 into the Since field and the flow would not run. I directly entered 4566.0 and the flow would run. In both cases, 4565.0 is in the data set and showed up in the JSON outputs and/or CSV.

 

This issue only seems to occur for records that exceed the versioning storage limits. In this case, 500 versions of a record are being stored and records with version labels 1-500 seem to work fine. However, for records with version labels greater than 500, the flow will not run if the user references the earliest version. If the user references the next version after the earliest (i.e. 4566.0 instead of 4565.0 in my case) the flow will run. 

 

Is there a way to report this as a potential bug to Microsoft?.

 

Matren_0-1659614686323.png

 

Matren_1-1659614712736.png

Matren_2-1659614942875.png

 

View solution in original post

16 REPLIES 16
David-
Solution Sage
Solution Sage

I think you would need to add a Get an item or file (properties only) before your Get changes for an item or file (properties only) action so you can get the current version number. Since you are storing only the last 500 versions, you can then use an expression to subtract 500 from the current version to use in the Since field for the Get changes action.

Hi David, Thanks for your response. I do not believe subtracting 500 will work for all our records. Many records in the list have less than 500 versions which would result in a negative number. It would be preferable if there was an expression that I could use that would always retrieve the lowest Version Label, regardless of what number it is. In addition, I could apply this to all our lists regardless of how many versions are being stored for that particular list. I would like not to have to enter a specific number to subtract, but rather a formula. I was thinking I would need to use Min, First (or Last), to obtain the lowest Version Label that is currently stored; however, I haven't been able to successfully derive the expression.

Sure it should, just use a condition that checks to see if the current version is over 500. If it is, on one side subtract 500 from the current version (or maybe you'll need to subtract 499), and if it is not, on the other side you can get all versions from version 1. Like:

Web capture_30-7-2022_14542_emea.flow.microsoft.com.jpeg

This is the expression for the since field:

 

sub(int(outputs('Get_item')?['body/{VersionNumber}']),500)
 
It's a solution unless someone has figured out a way to extract the lowest version saved.

Hi David, appreciate the response 🙂. As you mentioned, I'm looking for a solution that extracts the lowest version saved, making the solution applicable for any of our lists (which have different versioning settings) without having to subtract a different hard coded number for each list. It seems that a Minimum, First, or Last function might be employed in the solution, which references Version Label from the JSON outputed by Send_an_HTTP_request_to_SharePoint.

Hello Power Automate Community,

 

Still seeking assistance on this issue. I've gotten closer and am using the following expression:

 

last(outputs('Send_an_HTTP_request_to_SharePoint')?['body/value'])?['VersionLabel']

 

This yields the correct VersionLabel in compose functions; however, it throws an error in the Get Changes for SharePoint function.  It is saying that "Version Label does not correspond to any actual version."

 

Any suggestions?

 

Get Changes ExpressionGet Changes ExpressionCompose Outputs - No ErrorCompose Outputs - No ErrorGet Changes Outputs - ErrorGet Changes Outputs - Error

 

Perhaps the issue is that the output for VersionLabel is not being recognized as a number. You'll note the output is "4565.0" instead of 4565.0. Perhaps, I just need to use an int function; however, I haven't derived it yet.

 

 "VersionId"2337280,
  "VersionLabel""4565.0",
  "ID"1,

Hi @Matren 

 

typecast it as decimal

check https://youtu.be/Ek4oYWPWfT0

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Thanks,
Reza Dorrani, MVP
YouTube
Twitter

Since you are still having trouble with this, I have one improvement on what I proposed, which will do away with the condition. Add a Compose action between the Get item and Get changes for an item action:

David_0-1659468358379.png

The compose action will contain the following expression:

 

 

if(greater(int(outputs('Get_item')?['body/{VersionNumber}']),500),'500','1')

 

 

You place the output of this in the Since field for the Get changes...

 

Now to get what you want, I think you just have to replace the second 500 in my expression with an expression that will subtract 500 from the current version. So if your current version is 4500 it will return 4000.

 

Then whenever you want to use this, you just have to adjust it for how many versions you are keeping.

 

sub(int(outputs('Get_item')?['body/{VersionNumber}']),500)

 

 

 

Matren
Super User
Super User

Hi David, my requirement is to not use a hard coded number (i.e. 500). I think Reza is onto something by changing the output so that the since field recognizes the version label. I'm currently testing Reza's solution to typecast the following expression as a decimal. 

 

decimal(last(outputs('Send_an_HTTP_request_to_SharePoint')?['body/value'])?['VersionLabel']) 

Hi @RezaDorrani ,

 

Thanks for your response (and I love your youtube channel)!

 

Per your recommendation, I typecast the following expression as a decimal:

 

decimal(last(outputs('Send_an_HTTP_request_to_SharePoint')?['body/value'])?['VersionLabel']) 

 

However, the Get Changes Since Field still sent an error by not recognizing the VersionLabel. You'll note that the correct number is displayed (4565); however, perhaps it should be (4565.0)?

 

Version Label Decimal Typecast.pngVersion Label Get Changes Decimal functions.png

Matren
Super User
Super User

I've updated the since expression to:

 

formatnumber(int(last(outputs('Send_an_HTTP_request_to_SharePoint')?['body/value'])?['VersionLabel']),'0.0') 
 
which adds the decimal (i.e. 4565.0); however, still says the "Version Label does not correspond to any actual version."
 
It is interesting to note that the Power Automate flow works for records that have <= 500 versions.

I assume you tried using the created date in the Since field? Is there a reason that method does not work for you and you need to do it by version number? 

Web capture_3-8-2022_115339_emea.flow.microsoft.com.jpeg

 

 

formatDateTime(outputs('Get_item')?['body/Created'],'yyyy-MM-ddTHH:mm:ssZ')

 

This method has worked for me. I should have thought of this before, but since you were focused on getting the version number I lost sight of your end goal.

Hi David,

 

Using your recommendation, and tranforming it for this particular flow, yields:

 

formatDateTime(last(outputs('Send_an_HTTP_request_to_SharePoint')?['body/value'])?['Created'],'yyyy-MM-ddTHH:mm:ssZ')
 
 Running the flow, and looking at the output for "Get changes for an item or file (properties only)" function:
Matren_0-1659546679436.png

 

You'll note that the Since Version Number should be 4565.0 (the last version in the data); however, the function is changing it to 4566.0! We are storing 500 hundred versions so 5065-500 = 4565.

 

Also, Version Label 4565 is showing up in the data. This is underscored when I am not able to reference the last version label of 4565 in an expression for the "Since" field, because whenever I do, an error appears stating that Version Label 4565 can not be found (see previous screenshots posted to this thread). And yet, 4565 is outputed to the CSV table.

 

Matren_1-1659547493031.png

 

You'll note the 4565 and 4566 in the csv ouput have the SAME date time stamp. I've noted that some (but not all) of the date time stamps for the Versions repeat and I am unable to tell the difference in what changed for these versions.

 

By not referencing the earliest saved version, there is a risk that it won't correctly identify all the column changes.

 

 

 

Matren
Super User
Super User

@David- @RezaDorrani 

 

In summary, I think there may be a data issue or perhaps a bug. I directly entered 4565.0 into the Since field and the flow would not run. I directly entered 4566.0 and the flow would run. In both cases, 4565.0 is in the data set and showed up in the JSON outputs and/or CSV.

 

This issue only seems to occur for records that exceed the versioning storage limits. In this case, 500 versions of a record are being stored and records with version labels 1-500 seem to work fine. However, for records with version labels greater than 500, the flow will not run if the user references the earliest version. If the user references the next version after the earliest (i.e. 4566.0 instead of 4565.0 in my case) the flow will run. 

 

Is there a way to report this as a potential bug to Microsoft?.

 

Matren_0-1659614686323.png

 

Matren_1-1659614712736.png

Matren_2-1659614942875.png

 

Sorry, I cannot help then... The last suggestion I offered returns the last version available, as it is getting everything based on the date and time the item was created. There can be no versions before it was created.

Matren
Super User
Super User

Hi David,

 

As shown in posts above, using the creation date is returning the next to the earliest version. It appears that this occurs if either 1. there are records with version labels which have the same date time stamps (this happened in my dataset) or perhaps 2. there are version labels over the version storage limit (i.e. if storing 500 versions, having a record which has version greater than 500.

 

It would be preferable to reference the version label which appears to be unique in all cases.

 

As for how I am getting versions with the same datetimestamp ... perhaps they were created so close togther that it recorded the same value. I see it being recorded to seconds; however, I don't see any smaller time units being recorded.

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 (946)