Loading...

Saturday, February 11, 2012

SharePoint 2010 Social Features: Retrieve Noteboard data with SocialDataService.asmx

Noteboard is social data webpart for posting comments for any user activity.Read more..
To get Comments count on particular url
1)Add the jquery reference to masterpage
2)Invoke CountCommentsOnUrl webmethod of Social Data Webservice

<script type="text/javascript">
$(document).ready(function () {
var strURL = "http://server/Pages/PageWithNoteBoard.aspx?ID=3";
var CountMethod = '/_vti_bin/SocialDataService.asmx?op=CountCommentsOnUrl';

// var soapEnv = "<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><CountCommentsOnUrl xmlns='http://microsoft.com/webservices/SharePointPortalServer/SocialDataService'><url>+ strURL +</url></CountCommentsOnUrl></soap:Body></soap:Envelope>";

var soapEnv = "<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>
<CountCommentsOnUrl xmlns='http://microsoft.com/webservices/SharePointPortalServer/SocialDataService'>
<url>" + strURL + "</url>
</CountCommentsOnUrl>
</soap:Body>
</soap:Envelope>";


$.ajax({

url: CountMethod,
type: "POST",
async: true,
dataType: "xml",
data: soapEnv,
complete: proccessTagsAndNotes,
contentType: "text/xml; charset="utf-8""

});

function proccessTagsAndNotes(data, textStatus) {
alert(data.responseText);

var count = 0;
//alert(status);
//alert(xData.xml);
// count = $('CountCommentsOnUrlResponse', data).find('CountCommentsOnUrlResult').text();
count = $(data.responseText).find('CountCommentsOnUrlResult').text();


alert(' count' + count);


}

This code was working fine in my case but the link that helped me is here

1 comment:

Gowtham said...

can you help to get the comments by using var CountMethod = '/_vti_bin/SocialDataService.asmx?op=GetCommentsOnUrl';

while retriving the comments im getting empty value.
var commentCoun = $('GetCommentsOnUrlResponse', data).find('GetCommentsOnUrlResult').text();

soap syntax:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length







string
boolean


string
boolean