This project has moved and is read-only. For the latest updates, please go here.

SocialDataService CountCommentsOnUrl returns 'Undefined'

Jan 25, 2011 at 3:48 PM

When calling the Social Data service CountCommentsOnUrl operation with a specific article url as below

$().SPServices({ operation: "CountCommentsOnUrl",
url: 'http://myintranetsite/News/Pages/A

debug: true

The Soap request that gets created (copy of mine is below) appears to have two issues, firstly, the format of it should have <url> instead of <pageUrl> parameter, however looking at the logs it appears that the url I pass in has been wrapped in <pageUrl>

Secondly the url that I pass in is not the one that is passed to the service, the url passed below is the page I am calling the script from (in this case the default page for the site) and not the page I want to get user comments number for (in my case this is 'http://myintranetsite/News/Pages/Article1aspx')

<soap:Envelope xmlns:xsi='' xmlns:xsd='' xmlns:soap=''><soap:Body><WebUrlFromPageUrl xmlns='' ><pageUrl>http://myintranetsite/News/Pages/default.aspx</pageUrl></WebUrlFromPageUrl></soap:Body></soap:Envelope>
Jan 25, 2011 at 7:10 PM

I've answered my own question I think, in case anyone else encounters the same dilemma, below is a snapshot of the working script

$().SPServices({ operation: "CountCommentsOnUrl",
                                 async: false,
                                 url: pageUrl,
                                 completefunc: function (xData, Status) {
                                                                             $(xData.responseXML).find("CountCommentsOnUrlResult").each(function() {
                                                                                                                                                                commentsCountText = $(this).text();
                                                                                                                                                                commentsCountInt = $(this).nodeTypedValue();

Jan 25, 2011 at 7:27 PM


Sorry I didn't reply sooner, but I'm glad you solved it!