none
Sharepoint 2013 Discussion post get post id from Reply ID. RRS feed

  • Question

  • Hi All,

            In my newsfeed, Discussion post reply notification shown with the url as like http:\\sitename\Discussion\Dispform.aspx?ID=20. whenever i click this it will redirect to the Reply item in separate window. I just want this Dispform.aspx to redirect to original post url instead of reply item. I want the script to get the parent or post id from the Reply item id. Please help.


    Manikandan

    Friday, February 3, 2017 11:20 AM

Answers

  • Hi Manikandan,

    As a workaround, we can write a recursive function to get the post id using REST API.

    /_api/web/lists/getbytitle('Discussion')/items(20)/ParentItemID
     

    If the parent item id of the current id is null, it is a post id, else run the function get the parent id.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Manikandan J Wednesday, February 22, 2017 7:11 AM
    Monday, February 13, 2017 6:41 AM
    Moderator

All replies

  • Hi,

    We can get the parent item id using rest api.

    /_api/web/lists/getbytitle('Discussion')/items(20)/ParentItemID

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, February 6, 2017 9:13 AM
    Moderator
  • Hi Dennis,

    Thanks for your reply. The above code bring the Parent reply id for the current Reply post. If I give the parent Reply id as item id and then i will get the post id for the current ID. I want to get the Post ID from the grant child or Child reply id. Please help.


    Manikandan

    Tuesday, February 7, 2017 6:39 AM
  • Hi Manikandan,

    What do you mean about "If I give the parent Reply id as item id and then i will get the post id for the current ID"?

    Please provide some screenshots for further research.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, February 8, 2017 9:02 AM
    Moderator
  • Hi Dennis,

    In Discussion board I have one post and many people comment on this post, few reply comment on the existing comments. Mean Reply on already replied message, So if i give the last reply id then it will give me the previous reply id as the parent id. Here i want the post id instead of parent reply id.

    If the post has only one reply then parent id will be the post id. but in my condition i have many replies and few replies has child replies. Parent Id for the last reply giving the previous reply not the post id.

     


    Manikandan

    Friday, February 10, 2017 6:49 AM
  • Hi Manikandan,

    As a workaround, we can write a recursive function to get the post id using REST API.

    /_api/web/lists/getbytitle('Discussion')/items(20)/ParentItemID
     

    If the parent item id of the current id is null, it is a post id, else run the function get the parent id.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Manikandan J Wednesday, February 22, 2017 7:11 AM
    Monday, February 13, 2017 6:41 AM
    Moderator
  • Hi Dennis,

    Thanks for your reply. I have used your suggestion. It is working fine. 


    Manikandan

    Wednesday, February 22, 2017 7:11 AM