How do i get information about replies from a discussion forum

Oct 16, 2013 at 6:05 PM
I'm trying to get the total count of replies to a discussion forum post, as well as information about who replied, and also the ability to display the reply message (or the ID of the reply message). I'm able to get all of the information about the initial post, but just can't seem to find how to get the reply information.
Coordinator
Oct 16, 2013 at 7:34 PM
There are two different Content Types in a Discussion: Discussion and Message. The Message Content Type in the initial message and the Discussion Content Type is the rest of the thread. If you filter for Discussion, you should be all set.

M.
Oct 16, 2013 at 9:08 PM
I do grasp the concept of what you describe above, its just that at the moment I have no idea as to how that would be coded since I don't have much background with scripting (at the moment, but hope to get more engaged as I become familiar, AND have time!). Currently, I'm at the mercy of having to see examples to figure out the functionality, and then making the appropriate edits to achieve the output desired.
Oct 18, 2013 at 8:42 PM
I've been trying to read as much of the documentation and examples as I can, but I'm still not grasping how I go about filtering for the the Discussion Content type, as opposed to the Message content type. As seen below, im pretty much using the examples published on this site. The list is a discussion forum. The script works for displaying the Message Content type, so just trying to figure out the coding for how to filter for the Discussion content type.

$(document).ready(function() {
$().SPServices({
operation: "GetListItems",
async: false,
webURL: "(my web url is used here, I've removed name in this instance)",
listName: "Learning Feedback",
CAMLViewFields: "<ViewFields> <FieldRef Name='Title' /> <FieldRef Name='ID' /> <FieldRef Name='Editor' /> <FieldRef Name='Rate' /> </ViewFields>",
completefunc: function (xData, Status) {
  $(xData.responseXML).SPFilterNode("z:row").each(function() {
    var liHtml = "Subject: <strong>" +  $(this).attr("ows_Title") +  "</strong><br/>Rating:" +  $(this).attr("ows_Rate") + "<hr/ width='600px'>" ;
    $("#tasksUL").append(liHtml);
  });
}
});
});
</script>
<ul id="tasksUL"/>
Coordinator
Oct 23, 2013 at 3:22 PM
Edited Oct 23, 2013 at 3:50 PM
Tim:

It's a little tricky. The Discussion Content Type is based on Folder and the Message Content Type is based on Item. So to get all of the discussion items plus their replies, you need to add some CAMLQueryOptions.

If you run this, you should get all of the Discussion items plus all of the Message items because we're requesting that the Scope="RecursiveAll".
$().SPServices({
  operation: "GetListItems",
  async: false,
  listName: "Team Discussion",
  CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll'/></QueryOptions>",
  CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Body' /><FieldRef Name='ContentType' /></ViewFields>",
  completefunc: function (xData, Status) {
    $(xData.responseXML).SPFilterNode("z:row").each(function() {
      var liHtml = "Subject: <strong>" +  $(this).attr("ows_Title") +  "</strong><br/>Rating:" +  $(this).attr("ows_Rate") + "<hr/ width='600px'>" ;
      $("#tasksUL").append(liHtml);
    });
  }
});
Hit me back with any additional questions...

M.