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

rticle1aspx',
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='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><WebUrlFromPageUrl xmlns='http://schemas.microsoft.com/sharepoint/soap/' ><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();
                                                                                                                                                         });
                                                                        }   
                                });     

Coordinator
Jan 25, 2011 at 7:27 PM

elenabg:

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

M.