Preaching SharePoint

Retrieve Announcements using WebService in SharePoint

This is a quick code snippet to get Retrieve items in Announcements list using Web Service. Simply add the below in a CEWP and see the magic.

<script  type="text/javascript" src=""></script>

<script type="text/javascript">

  function GetAnnouncements(){
  var soapEnv = "<soap:Envelope xmlns:soap=''> \
                 <soap:Body> \
                 <GetListItems xmlns=''> \
                  <listName>Announcements</listName> \
                   <viewFields> \
                   <ViewFields> \
                    <FieldRef Name='Title' /> \
                    <FieldRef Name='Body' /> \
                    <FieldRef Name='Expires' /> \
                  </ViewFields> \
                 </viewFields> \
                </GetListItems> \
                 </soap:Body> \
                  url: "/_vti_bin/lists.asmx",
                  type: "POST",
                  dataType: "xml",
                  data: soapEnv,
                  complete: GetListItemsComplete,
                  contentType: "text/xml; charset=\"utf-8\""
function GetListItemsComplete(xData, status) {
  jQuery(xData.responseXML).find("z\\:row").each(function () {
    $("<li>" + $(this).attr("ows_Title") + "</li>").appendTo("#Announcements");
<a href="#" onclick="Javascript:GetAnnouncements();">Get Announcements</a>

<ul id="Announcements"></ul>


0 Respones to "Retrieve Announcements using WebService in SharePoint"

Post a Comment


Do you want SharePoint 2013 to inherit Metro Style design?

Search This Blog

Return to top of page Copyright © 2010 | Platinum Theme Converted into Blogger Template by HackTutors