How to create new Discussion Item/Reply

Jan 19, 2010 at 9:49 AM

How can we use "UpdateListItems" to create a new discussion reply?

I've tried:

 

$().SPServices({
        operation: "UpdateListItems",
        webURL: siteURL,
        async: false,
        listName: list,
        updates: "<Batch OnError='Continue'>" +
        "<Method ID='1' Cmd='New'>" +
            "<Field Name='ContentType'>Message</Field>" +
            "<Field Name='ContentTypeId'>0x01070099E44219217F5742940F0898CAD630EE</Field>" +
            "<Field Name='ParentFolderId'>1</Field>" +
            "<Field Name='Rating'>" + rating + "</Field>" +
        "</Method></Batch>",
        completefunc: function(xData, Status) {
            alert("finished! " + xData.responseXML.xml);
        }
    });*/
$().SPServices({
        operation: "UpdateListItems",
        webURL: siteURL,
        async: false,
        listName: list,
        updates: "<Batch OnError='Continue'>" +
        "<Method ID='1' Cmd='New'>" +
            "<Field Name='ContentType'>Message</Field>" +
            "<Field Name='ContentTypeId'>0x01070099E44219217F5742940F0898CAD630EE</Field>" +
            "<Field Name='ParentFolderId'>1</Field>" +
            "<Field Name='Rating'>" + rating + "</Field>" +
        "</Method></Batch>",
        completefunc: function(xData, Status) {
            alert("finished! " + xData.responseXML.xml);
        }
    });

but it still inserts as a new discussion item rather than replying to an existing Discussion item with ID=1 in the forum.

Thanks in advance!

 

 

 

Coordinator
Jan 19, 2010 at 2:40 PM

coded:

I haven't played around with discussions much with the Web Services, but I just did a quick Bing and found this article for you: http://geekswithblogs.net/kobush/archive/2007/03/12/108545.aspx (Note that there's a link to a second article at the bottom.)  The approach in the article is different, but it gives a good overview of how discussions are constructed.

The bottom line is that this is certainly possible, but I don't have an example for you.  If you come up with a workable example, please post it back to benefit others!

M.

Jan 20, 2010 at 12:39 AM

Thanks for the resource. There's 2 very useful functions if I'm programming in .NET (SPUtility.CreateDiscussion and SPUtility.CreateDiscussionReply). Anyone knows if there's an equivalent in JQuery?

Coordinator
Jan 20, 2010 at 1:03 AM

It's not whether there's something equivalent in jQuery, but something equivalent in the SharePoint Web Services.  All that I (or anyone else I know) am doing is wrapping the Web Services in more easily managed jQuery functions.  I think you're still going to need to figure out how to translate the capabilities which are available in SPUtility.CreateDiscussion and SPUtility.CreateDiscussionReply into the existing Web Service operations.

Try posting the question over at the EndUserSharePoint.com Stump the Experts form.  I'm a moderator over there, and I think that there may be folks who could help move this forward with you.

M.