web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : 9w6UOu5YNPf+A0wZLq+cUz
Power Automate - Building Flows
Answered

Exporting Sharepoint list comments in a user friendly way

Like (0) ShareShare
ReportReport
Posted on 17 Jan 2024 15:58:27 by 774

Im following the solution found here: Solved: Exporting SharePoint List Comments - Beginner Frie... - Power Platform Community (microsoft.com), altough to be specific, the one that the user then suggested on β€Ž03-15-2023 07:19 PM

I'm getting only the first comment for that item and apart from that, a bunch of text like "Author: {"__metadata":{"type":"SP.Sharing.Principal"},"directoryObjectId":null,"email":"

All the needed info is there but it is buried with all that extra text. So, what is lacking in that flow to make it so it collects all coments and only shows the necessary info (date, author, text, etc) 

 

This is the flow I'm working with:

1- Spanish, sorry 😞 But they are all string variables

1.PNG

This is another string variable, then Get Items, then the HTPS 

 

2-2.PNG

the condition set that the Body of the HTPS action contains "Results": []

 

The JSON code is the same the other guy used. Meaning:

{
    "type""object",
    "properties": {
        "d": {
            "type""object",
            "properties": {
                "results": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "__metadata": {
                                "type""object",
                                "properties": {
                                    "id": {
                                        "type""string"
                                    },
                                    "uri": {
                                        "type""string"
                                    },
                                    "type": {
                                        "type""string"
                                    }
                                }
                            },
                            "likedBy": {
                                "type""object",
                                "properties": {
                                    "__deferred": {
                                        "type""object",
                                        "properties": {
                                            "uri": {
                                                "type""string"
                                            }
                                        }
                                    }
                                }
                            },
                            "replies": {
                                "type""object",
                                "properties": {
                                    "__deferred": {
                                        "type""object",
                                        "properties": {
                                            "uri": {
                                                "type""string"
                                            }
                                        }
                                    }
                                }
                            },
                            "author": {
                                "type""object",
                                "properties": {
                                    "__metadata": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "directoryObjectId": {},
                                    "email": {
                                        "type""string"
                                    },
                                    "expiration": {},
                                    "id": {
                                        "type""integer"
                                    },
                                    "isActive": {
                                        "type""boolean"
                                    },
                                    "isExternal": {
                                        "type""boolean"
                                    },
                                    "jobTitle": {},
                                    "loginName": {
                                        "type""string"
                                    },
                                    "name": {
                                        "type""string"
                                    },
                                    "principalType": {
                                        "type""integer"
                                    },
                                    "userId": {},
                                    "userPrincipalName": {}
                                }
                            },
                            "createdDate": {
                                "type""string"
                            },
                            "id": {
                                "type""string"
                            },
                            "isLikedByUser": {
                                "type""boolean"
                            },
                            "isReply": {
                                "type""boolean"
                            },
                            "itemId": {
                                "type""integer"
                            },
                            "likeCount": {
                                "type""integer"
                            },
                            "listId": {
                                "type""string"
                            },
                            "mentions": {
                                "type""object",
                                "properties": {
                                    "__metadata": {
                                        "type""object",
                                        "properties": {
                                            "type": {
                                                "type""string"
                                            }
                                        }
                                    },
                                    "results": {
                                        "type""array"
                                    }
                                }
                            },
                            "parentId": {
                                "type""string"
                            },
                            "replyCount": {
                                "type""integer"
                            },
                            "text": {
                                "type""string"
                            }
                        },
                        "required": [
                            "__metadata",
                            "likedBy",
                            "replies",
                            "author",
                            "createdDate",
                            "id",
                            "isLikedByUser",
                            "isReply",
                            "itemId",
                            "likeCount",
                            "listId",
                            "mentions",
                            "parentId",
                            "replyCount",
                            "text"
                        ]
                    }
                }
            }
        }
    }
}

3.PNG

A for each following the JSON, setting all the created string variables to the values I want

4.PNG

A Compose action for all the created variables except the one that will have all "todo junto". And the append to string action to add to that variable the rest of variables with the outputs of the recent compose one. This closes the For all and conditional.

 

5.PNG

6.PNG

Adding the variable to the sharepoint list column. 

As mentioned, it does have all the data I need, but not user friendly. And only for the first comment.

7.PNG

  • WorkingRicardo Profile Picture
    774 on 19 Jan 2024 at 10:49:12
    Re: Exporting Sharepoint list comments in a user friendly way

    I managed to do it as I wanted πŸ˜„ With chatgpt lol @eliotcole 

    I used: 

    concat(
     item()?['author/name'], 
     ' comentΓ³ ', 
     item()?['text']
    )

    So if i comented hello it would just be "Ricardo comentΓ³ hola".

    Thank you soooooooooooooooooo much again!

  • WorkingRicardo Profile Picture
    774 on 19 Jan 2024 at 08:54:36
    Re: Exporting Sharepoint list comments in a user friendly way

    Hey again @eliotcole, thanks for sticking with me through this.

    So, I recopied the HTML after the HTTP action and now the dynamic ['d/results'] showed up as you screenshot. However, I get the comments like this: 

    <p><strong>By: <em><a href="NAME@EMAIL.COM">FIRST AND LAST NAME</a></em></strong><br/>CommentedCOMMENT</p>

     

    Would it be possible to get it without those strong and <p> things?
    Just "By: Ricado 
    Commented: "hello"

  • eliotcole Profile Picture
    4,266 Moderator on 18 Jan 2024 at 15:07:29
    Re: Exporting Sharepoint list comments in a user friendly way

    On Content

    Yeah ... pretty much:


    @WorkingRicardo wrote:

    Oh for this actionof SelectResultstoHTML how did you get the dynamic content for results? I used an expression "

    body('Enviar_una_solicitud_HTTP_a_SharePoint')?['d/results']". Is that right like that?

     

    WorkingRicardo_0-1705588093391.png


    On The HTML Comments

    You also asked:


    @WorkingRicardo wrote:

    @eliotcole Omg that put the comments in all items! Altough it put the whole of the metada 😞
    Would it be possible if I commented: hello to get it like this:
    "By: Ricardo@email.com

    Commented: "hello"


    So ... if you look at the end of my reply you will see the concat() which is in the Mapa/Map field of the select.

     

    Each of those there is just referring to either a piece of text that is being inserted:

     

     '<p>'

     

    ... or picking some data from the item() to insert:

     

     item()?['Author']

     

    Then it just pulls it all together!

     

    To make it not have the date, just edit the first few parts:

     

    concat(
     '<p><strong>By: <em><a href="', 
     item()?['author/email'], 
     '">', 
     item()?['author/name'], 
     '</a></em></strong><br/>Commented: ', 
     item()?['text'], 
     '</p>'
    )

     

     

    Which makes me notice that I'd made an HTML error in my previous reply so I have updated that now!

  • WorkingRicardo Profile Picture
    774 on 18 Jan 2024 at 14:26:51
    Re: Exporting Sharepoint list comments in a user friendly way

    @eliotcole Omg that put the comments in all items! Altough it put the whole of the metada 😞
    Would it be possible if I commented: hello to get it like this:
    "By: Ricardo@email.com

    Commented: "hello"

     

    Oh for this actionof SelectResultstoHTML how did you get the dynamic content for results? I used an expression "

    body('Enviar_una_solicitud_HTTP_a_SharePoint')?['d/results']". Is that right like that?

     

    WorkingRicardo_0-1705588093391.png

     

    Maybe because I did it this ways is why I can't get it fully correct.
    At the moment it works but would be difficult to explain to my colleagues how it is... They did told me they only need it by who and the what, no date needed. I say by email because maybe its easier to get it, as by name the claims and all that data would need to be removed somehow... I mean if its possible I'd preferred it before the email.
    Ty again so much! I didn't know you could copy Flows like that :o!!!

  • Verified answer
    eliotcole Profile Picture
    4,266 Moderator on 18 Jan 2024 at 12:20:05
    Re: Exporting Sharepoint list comments in a user friendly way

    First up, thanks for updating the question, @WorkingRicardo, that is really great information and helps a lot. πŸ™‚ πŸ‘

     

    I've made something that slightly resembles your flow, here:

    Get Comments Flow - 2.png

     

    If you want you can make yours very similar to that, by adding an action after  your 'Enviar una solicitud HTTP a SharePoint' action, going to the 'My clipboard' tab, and then paste this in:

     

     

    {"id":"b5238f28-d447-40e4-a724-514bd13caa33","brandColor":"#484F58","connectionReferences":{"shared_sharepointonline_1":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-70a14524-6d74-4196-b1fc-31d350117f82"}},"shared_sharepointonline":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/d77dac51a9a54000bd7e766fd7769f04"}}},"connectorDisplayName":"Control","icon":"data&colon;image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iLTQgLTQgNjAgNjAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+DQogPHBhdGggZD0ibS00LTRoNjB2NjBoLTYweiIgZmlsbD0iIzQ4NEY1OCIvPg0KIDxwYXRoIGQ9Ik00MSAxOC41di03LjVoLTMwdjcuNWg1LjY0djEzLjgzbC0zLjI4NS0zLjI4NS0xLjA2NSAxLjA2NSA0LjAzNSA0LjA1Ljg3Ljg0aC02LjE5NXY2aDEzLjV2LTZoLTYuOWwuODU1LS44NTUgNC4wMzUtNC4wNS0xLjA2NS0xLjA2NS0zLjI4NSAzLjI4NXYtMTMuODE1aDE1djEzLjgzbC0zLjI4NS0zLjI4NS0xLjA2NSAxLjA2NSA0LjAzNSA0LjA1Ljg3Ljg0aC02LjE5NXY2aDEzLjV2LTZoLTYuOWwuODU1LS44NTUgNC4wMzUtNC4wNS0xLjA2NS0xLjA2NS0zLjI4NSAzLjI4NXYtMTMuODE1em0tMjguNS02aDI3djQuNWgtMjd6IiBmaWxsPSIjZmZmIi8+DQo8L3N2Zz4NCg==","isTrigger":false,"operationName":"Condition_MoreThanOneResult","operationDefinition":{"type":"If","expression":{"greater":["@length(body('Enviar_una_solicitud_HTTP_a_SharePoint')?['d/results'])",0]},"actions":{"SelectResultsToHtml":{"type":"Select","inputs":{"from":"@body('Enviar_una_solicitud_HTTP_a_SharePoint')?['d/results']","select":"@concat(\r\n '<p><strong>', \r\n item()?['createdDate'], \r\n ' - <em><a href=\"', \r\n item()?['author/email'], \r\n '\">', \r\n item()?['author/name'], \r\n '</a></em></strong><br/>', \r\n item()?['text'], \r\n '</p>'\r\n)"},"runAfter":{}},"JoinHtmlForCommentarios":{"type":"Join","inputs":{"from":"@body('SelectResultsToHtml')","joinWith":"\n"},"runAfter":{"SelectResultsToHtml":["Succeeded"]}}},"runAfter":{"Enviar_una_solicitud_HTTP_a_SharePoint":["Succeeded"]},"metadata":{"operationMetadataId":"a3f9c522-ebe8-4278-a6e0-58a55202d9bd"}}}

     

     

     

    You can see the two Select actions there and you can also see that I am using a more accurate way to test if there are any comments. The expression in the left side is calculating the amount of comments for the list item:

     

     

     

    length(body('Enviar_una_solicitud_HTTP_a_SharePoint')?['d/results'])

     

     

     

    Then the condition and right side check that the number calculated is greater than 0.

     

    All you would need to do after this is to place your 'Actualizar elemento' ('Update item') action and in the 'commentarios' value add the output from the 'JoinHtmlForCommentarios' action that I made.

     

    It might look something like this, then:

    Get Comments Flow - 3.png

     

    The 'SelectResultsToHtml' action is where I did a bit of clever stuff using the following expression with a concat() function connecting together pieces of text and values from the comments request results into one HTML paragraph.

     

    concat(
     '<p><strong>', 
     item()?['createdDate'], 
     ' - <em><a href="', 
     item()?['author/email'], 
     '">', 
     item()?['author/name'], 
     '</a></em></strong><br/>', 
     item()?['text'], 
     '</p>'
    )

     

    Because this sits in the 'Map' section of the Select action, it can address each item() programmatically. To select an individual key's value with the item() funtion you would use something like item()['keyName']. This would then place the value of that key name into the produced Select.

     

    Even though the above looks complex, it is actually making a simple array, with only text entries. Each entry will correstpond to the comment that was entered, and makes its own '<p>' information for the HTML. πŸ™‚

  • WorkingRicardo Profile Picture
    774 on 18 Jan 2024 at 07:58:47
    Re: Exporting Sharepoint list comments in a user friendly way

    Hey guys! Thanks you both with your replies. I edited my first post to show my full flow. Sorry its in Spanish, I tried to translate where needed.

    @Expiscornovus Thanks for the suggestion! I read the blog post and ugh... Couldn't understand much of it. I'm still a novice at all this 😞

    @eliotcole  And noooo! Thanks for explaining that. I literally have 0 base knowledge of coding so that helped a it πŸ™‚

    Anyhoooow. Having my flow, do you know where I should put the "For each" so it grabs all comments? Or how I could simplify even the text?
    Ty in advance!

  • eliotcole Profile Picture
    4,266 Moderator on 17 Jan 2024 at 16:49:00
    Re: Exporting Sharepoint list comments in a user friendly way

    Hi, @WorkingRicardo, a brief look at that solution shows an awful lot of Apply to each and Parse JSON actions.

     

    Whilst these are simple enough when you are building, they can introduce problems if the Parse JSON does not have a very specific setup (allowing for NULL values and suchlike), which result in flow issues.

     

    Plus, since it leans on HTTP actions, this somewhat makes it in odds to the Parse JSON stuff.

     


     

    I hope that the next part does not come across in a condescending manner, but I would advise that you familiarise yourself with a few JSON concepts:

    • Key/Value 'Pairs' - These are how information is kept in a JSON file:
      • Key - This is the name of the field (think of it as the name of a SharePoint list column)
      • Value - This is the value of the field (think of this as the content in the column)
    • Object - A singular entity potentially containing one or more sets of key/value pairings
    • Array - An array is a collection of information, it can be a simple one which just contains a set of strings or something, or it can be a more complex collection consisting of many Objects

    There are tutorials and guides online which will give you more understanding of these, but essentially they are things you will commonly use in flows. You will build up more knowledge with them the more that you use them. I've added some real simple examples in the below spoiler.

    Spoiler (Highlight to read)
    Here is an Object
    {
     "key": "value",
     "key2": 2,
     "key3": true
    }​

    Here is a simple Array
    [
     "Value 1",
     "Value 2",
     "Value 3",
     "Value 4"
    ]​


    Here is a complex Array
    [
     {
     "key": "value 1",
     "key2": 1,
     "key3": true
     }​
     {
     "key": "value 2",
     "key2": 2,
     "key3": false
     }​
     {
     "key": "value 3",
     "key2": 3,
     "key3": true
     }​
    ]​
    Here is an Object{ "key": "value", "key2": 2, "key3": true }​Here is a simple Array[ "Value 1", "Value 2", "Value 3", "Value 4" ]​Here is a complex Array[ { "key": "value 1", "key2": 1, "key3": true }​ { "key": "value 2", "key2": 2, "key3": false }​ { "key": "value 3", "key2": 3, "key3": true }​ ]​

     

    I think, though, in order for anyone to help you more with this it would be better for you to update your original question (above) with imagery of your flow embedded into the question. I specifically mention to embed it (use the camera button in the editor) because

  • Expiscornovus Profile Picture
    32,169 Most Valuable Professional on 17 Jan 2024 at 16:45:04
    Re: Exporting Sharepoint list comments in a user friendly way

    Hi @WorkingRicardo,

     

    Can you share a screenshot of your current flow setup? This will help troubleshoot why you are only getting the first comment and not the rest of the comments.

    It looks like the solution you are referring to loops through all the comments via an apply to each and the results property. So in theory that solution should retrieve all comments.

     

    Alternatively, you could also have a look at this blog from @DamoBird365 about list comments:

    https://www.damobird365.com/microsoft-list-add-comment/

     

    In that blog he has a section about reading all comments and formatting it into readable format. That might also be a good one to have a look at.

     

     

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete