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

Export Sharepoint list items with comments into CSV file

Hi everyone, I've followed this blogpost (https://divyeshkotadia.wordpress.com/2023/04/21/how-to-export-list-items-with-comments-into-excel-cs...) and it has me 95% of the way there but there are two issues.

 

1. The @mentions in comments when they are linked in o365 do not show the username/email of the individual but the replace function the creator used. (if you are viewing the blogpost this is the step I'm referring to Replace mentions in comment)

Mag1c_0-1698174553761.png

 

 

For instance it should be @John Smith but it says @mention{0} instead. I'm not quite sure why this is and how to resolve it. We have sometimes 10+ comments on a single Sharepoint list item with multiple people mentioned in the comment so I would love to get this resolved.

 

2. This issue is less important but the comments are listed newest to oldest, how can I get them to list oldest to newest (first comment to latest comment).

 

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Mag1c,

 

To add those fields you can include them in the first Select, directly after the Send an HTTP request to SharePoint action. You also need to change the expression for the Text field as well, that it does not include the date time anymore.

 

Below is an example

 

1. Changed the Select to use the below

{
  "Created": @{formatdatetime(item()?['createdDate'],'dd-MM-yy HH:mm')},
  "CreatedBy": @{item()?['author/Name']},
  "Text": @{item()?['text']},
  "Mention": @{item()?['mentions']?['results']}
}

 

select_author.png 

2. Change the Add a row action to use the below of the two new fields

 

item()['CreatedBy']

 

item()['Created']

 

addarowintoatable.png

 

 

3. The export should now look like the below

 

comments_export.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


View solution in original post

18 REPLIES 18
Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Mag1c,

 

Have a look at the Read ALL comments part of this blog from @DamoBird365https://www.damobird365.com/microsoft-list-add-comment/

 

That blog demonstrates how to replace those references with the actual names of the people mentioned by using a couple of Select actions and some expressions with split and replace functions.



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


I appreciate your response. I tried following the blog but I get an error “the action join_objects is nested in a foreach scope of multiple levels. Referencing repetition actions from outside the scope is supported only when there are no multiple levels of nesting"

This is due to the REST API call to fetch all comments being a loop because I want to pull all of the records and its comments from a list, not just a single record and its comments. Any ideas on how to work around this?

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Mag1c,

 

It should also be possible to retrieve all comments from all items.

 

Because you already have a for each loop that one from the blog would be a nested one. That also means that you would have to update the expressions which are being used in the blog to point to the right for each loop action. Make sure that is is using the correct action name in the items function.

 

Can you share a screenshot of how you added the actions from the blog. This way I can easier point to what you need to change/update to make this work.



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Sure, I've attached 3 screenshots of my flow. I changed the original quite a bit to add in the parts from the blog you mentioned and haven't cleaned it up yet as I'm testing so there are still some variables listed that won't be needed once it's working.

Hello @Expiscornovus @I provided 3 screenshots if you’re able to assist me with the error. Thanks!

Bumping this topic in case anyone can assist, thanks!

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Mag1c,

 

Apologies for the delayed reply and thanks for sharing those screenshots. 

 

It looks like the issue might be in your Join Objects action. However, it the screenshot it is collapsed. I cannot see what your are using in that action. Can you share what you used in that action?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


I've just copied/pasted the expression from the article you posted:

if(equals(length(item()?['mention']),0),items('Apply_to_each')?['text'],concat(join(body('Select_Text_and_Replace_Mention'),''),last(outputs('Split_on_Mention_Compose'))))

I think the issue is with my expression in the compose action. The article says this

Mag1c_0-1699367559728.png

but if I put exactly that code in as an expression it gives me an error saying it's invalid

 

@{outputs('join_objects')}

 

If I try it as the below code, it saves the expression but when I click save on the flow is when I get the error below.

 

outputs('join_objects')

 

 

 

 Flow save failed with the code 'invalidtemplate' and message 'the template validation failed: 'the inputs of the template action 'compose' at line '1 and column '5290' cannot reference action 'join_objects'. The action 'join_objects' is nested in a foreach scope of multiple levels. Referencing reptition actions from outside the scope is supported only when there are no multiple levels of nesting.

 

Bumping again to see if anyone is able to assist with this?

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Mag1c,

 

Sorry, I get a lot of notifications so I missed this one again, my bad 😅

 

My guess is that the compose is in the wrong location. Is that compose action outside the apply to each loop? If that is the case you will get this error message. Place the compose within the loop.

 

Btw, if you want to store all text you probably want to use a string variable (initialize variable action at the beginning of your flow) and use an append to string variable action at the end of each loop.

 

compose_withinapplytoeach.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


@Expiscornovus  My compose action was outside of the apply to each loop but even when I add it inside I still get an error:

 

Mag1c_0-1699969363391.png

 

Just to refresh as this has been an issue going on a couple of weeks... the initial flow I was using works but has the issue with the @mention in comments showing the code instead of the user's name. - https://divyeshkotadia.wordpress.com/2023/04/21/how-to-export-list-items-with-comments-into-excel-cs... this is the flow I'm referencing. 

 

You suggested this flow - https://www.damobird365.com/microsoft-list-add-comment/ , to resolve the issue, which it does but only for a single ID in a sharepoint list, not all the of rows/IDs in a sharepoint list which is what I need. I am attemping to export all of the comments out of the list one time.

 

Essentially, I just need help converting https://www.damobird365.com/microsoft-list-add-comment/ from one single ID to exporting all of the comments in a SP list to a spreadsheet. I tried combining the two referenced flows but am clearly having some issues. 

 

I hope that helps provide some clarity on this and you can help me resolve, I really appreciate it!

 

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Mag1c,

 

I think you are pretty close. In that case I would suggest to add a Add a new row in table action directly after the Join Objects action (still within the Apply to each loop).

 

Below is an example

 

ID field of my table uses

items('Loop_through_items_for_comments')['id']

 

Comment Text field of my table uses the Outputs of the Join Objects action

outputs('Join_Objects')

 

addarowintotable.png

 

Test result is the below

 

exporttofile.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


@Expiscornovus THANK YOU SO MUCH! I just have a couple of follow up questions, how can I add a column with the creator/user who submitted the comment (submitted by) and the date/time stamp of when they added it? I've tried a few things but I'm missing something.

Mag1c_0-1699986838592.png

 

Lastly, it looks like it's not handling special characters well, specifically the "&" and ":". For the "&" it says "&" and the ":" it says ":". Not really huge issues as I can resolve them with power BI, as that's how I plan to merge the comments to a single row anyways.

 

THANKS AGAIN SO MUCH, nearly there!

Expiscornovus
Most Valuable Professional
Most Valuable Professional

Hi @Mag1c,

 

To add those fields you can include them in the first Select, directly after the Send an HTTP request to SharePoint action. You also need to change the expression for the Text field as well, that it does not include the date time anymore.

 

Below is an example

 

1. Changed the Select to use the below

{
  "Created": @{formatdatetime(item()?['createdDate'],'dd-MM-yy HH:mm')},
  "CreatedBy": @{item()?['author/Name']},
  "Text": @{item()?['text']},
  "Mention": @{item()?['mentions']?['results']}
}

 

select_author.png 

2. Change the Add a row action to use the below of the two new fields

 

item()['CreatedBy']

 

item()['Created']

 

addarowintoatable.png

 

 

3. The export should now look like the below

 

comments_export.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #MicrosoftCopilotStudio content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


fireballs
Frequent Visitor

I have a similar issue- I can generate a correct replacement for the first @mention ID - but each @ mention after the first one returns the @mention{0} instead in the CSV 

 

fireballs_0-1710269856325.png

fireballs_1-1710269878785.png

fireballs_2-1710269894903.png

fireballs_3-1710270024450.png

 

fireballs
Frequent Visitor

Figured this out by reseting the mentionID integer to -1 within the loop

 

New problem: multiple @ mention IDs do not get updated within the one comment, only the first one!

fireballs
Frequent Visitor

Solved - moved the MentionID integer reset to AFTER the loop.

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