Is there a way to get First comment date from blog Post?

I have been trying this code 

#foreach ($blog in $blogList)
#set ($blogComment = $core_v2_comments.List("%{  ContentId : $blog.ContentId }"))
#set ($comment = $blogComment.get_item(0))
<tr>
<td>$blog.Name</td>
<td>$blog.Group.GroupType</td>
<td>$blog.PostCount</td>
<td>$blog.CommentCount</td>
<td>$blog.DateCreated</td>
<td>$comment.CreatedDate</td>
</tr>
#end

which is giving me same date value for all the blogs, which is actually wrong, so can anyone help me out with this

Parents
  • Former Member
    +1 Former Member

    Is $blogList a list of blogs or blog posts?  If its blogs you are retrieving comments directly on the blog application, not individual blog posts.  If you are looking for the latest comment on any post in a blog, the property would be ApplicationId not ContentId

    You also do need to retrieve an entire list of blog posts if you only care about 1.  Use a sort and PageSize 1 to just retrieve the newest comment.

    Newest comment on a blog post

    $core_v2_comments.List("%{ ContentId = $blogpost.ContentId, PageIndex = 0, PageSize = 1, SortBy = 'CreatedUtcDate', SortOrder = 'Descending }")

    Newest comment on any blog post in a blog

    $core_v2_comments.List("%{ ApplicationId = $blog.ContentId, PageIndex = 0, PageSize = 1, SortBy = 'CreatedUtcDate', SortOrder = 'Descending }")

  • Same Logic, When I am trying for Forums, it's not working, Like logic to find Newest comment on any forum post in a forum I was trying, so Please can you help me with that too

Reply Children