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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Include Comment Versio...
Power Automate
Answered

Include Comment Version History in email sent from SharePoint List

(0) ShareShare
ReportReport
Posted on by 22

Hi Team,

 

I have used the Power Automate Template "Send email from shared mailbox when existing item is modified in SharePoint", which works great, except I have one small issue I am hoping I could please get assistance on? 

I have a "Comments" column which team members can go in and add their comments. I have turned on "Item Version History" and "Append changes to existing text" for this column. When I go into the list and the comment field it has the full date & timestamp and everything looks fine, however when it sends the email it only provides the latest comment? I would like to include the full comment history in the email, does anyone know of a way to do this?


Thanks in advance
 

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

    Hi @grahamr,

     

    If you want to get history comments, you should get history versions. You could use Send HTTP request to SharePoint to get these versions of the file or item.

    The URI is:

    _api/web/lists/getbytitle('List')/items(itemID)/versions

    Annotation 2020-05-27 171658.jpg

     

    Then you could initialize an array variable to hold these comments.

    The following expression means to get the array of versions:

    body('Send_an_HTTP_request_to_SharePoint')?['d']['results']

    Then put the array into apply to each action to loop through each version, append their comments into the Comments array variable:

    Annotation 2020-05-27 171858.jpg

    This is the code in the Value field: 

    {
     "comments": "@item()?['OData__x005f_ModerationComments']"
    }

    After all, you could convert the comments variable into an HTML table to make it could be inserted into the EMail body:Annotation 2020-05-27 172528.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • grahamr Profile Picture
    22 on at

    Thanks for the detailed response! I am just having a few minor issues, apologies this is prob really basic..

    For the "Send an HTTP request to SharePoint" I have modified your syntax "_api/web/lists/getbytitle('List')/items(itemID)/versions" to accommodate my scenario...

    My List NameCB AU - OCDD

    Column Name = Comments

    Item = 12 item <-- Is this column position?

     

    I've changed the variables as per below:
    _api/web/lists/getbytitle('CB AU - OCDD')/items(12)/versions

    But it's erroring with a 400, Item does not exist.

    Thanks again for your help so far!


  • v-litu-msft Profile Picture
    on at

    Hi @grahamr,

     

    The 12 is itemID, you could get it from the trigger body.

    If list name is CB AU - OCDD, the system name should be "CB AU OCDD", so the uri should be:

    _api/web/lists/getbytitle('CB AU OCDD')/items(itemID)/versions

    Annotation 2020-05-28 171731.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • grahamr Profile Picture
    22 on at

    I am getting closer and closer! apologies, this relatively new to Power Automate. I have not got it to send me an email but the body contains a lot of unstructured lookup info... It seems like versions for all rows, just not the version for comments. I think it might be wrong syntax I have put in for the Array. I've included screen shot below

     

     

    2020-05-29_13-42-13.jpg

    For item() I literally just created an expression and put in item() - I know you had in below but wasn't sure if I had to put that in the expression? of create

    {
    "comments": "@item()?['OData__x005f_ModerationComments']"
    }

     

    Thanks again for your assistance

  • Verified answer
    v-litu-msft Profile Picture
    on at

    Hi @grahamr,

     

    Ok, so the comments column is the custom column create by yourself, not system column?

    If so, please try:

    {

    comments": "@item()?['Comments']

    }

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • grahamr Profile Picture
    22 on at

    Correct, the column I am working with "Comments" was created by me and is not system column. So I am just trying to append all the versions of the Comments column into the email. 

    When I try and input that code, it gives an error.

    2020-05-30_12-51-53.jpg

    I also just wanted to confirm my syntax below, should this be the "Comments" variable 
    2020-05-30_12-54-50.jpg

    or should this be the ID variable?

    2020-05-30_12-59-59.jpg

     

    It didn't seem to like your initial suggestion of "If list name is CB AU - OCDD, the system name should be "CB AU OCDD" so I put back to "CB AU - OCDD"

     

    I feel like i'm so close! 

    Thanks a million for your help!

  • v-litu-msft Profile Picture
    on at

    Hi @grahamr,

     

    Enter the expression should in the Expression bar:

    Annotation 2020-06-02 144947.jpg

     

    The two setting in the items should be this:

    Annotation 2020-06-02 145148.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • grahamr Profile Picture
    22 on at

    Hi Community Support Team _ Lin Tu,

     

    So I've gotten further and am sooo close... Basically, I am now getting an email with the version history for comments (highlighted in red) but it is including a bunch of other info I don't need. Please refer to screenshot below:

     

    2020-06-05_10-11-18.jpg

    Are you able to please further assist me in getting rid of this additional info? 

    Thanks for your detailed responses! I couldn't have gotten this far without you.

     

  • v-litu-msft Profile Picture
    on at

    Hi @grahamr,

     

    Use HTML to text action could convert HTML code into simple text:

    Annotation 2020-06-05 163207.jpg

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • grahamr Profile Picture
    22 on at

    That Worked, thanks so much! Sorry just one more thing!

    It is coming through like this

    2020-06-07_14-10-04.jpg

    But I would like it to include the person, and date? Similar to this..
    2020-06-07_14-07-23.jpg

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard