2011-08-26 59 views
1

我使用一个Web服务,我试图返回从帖子列表与视图名{B9212691-1AF1-41AF-9DA7-6073ADDB091B}最高ID号。 到目前为止,我有以下。的Sharepoint:试图获取最新的ID

<script type="text/javascript"> 
    $(document).ready(function() { 
     var soapEnv = 
      "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \ 
       <soapenv:Body> \ 
        <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \ 
         <listName>Posts</listName> \ 
         <viewName>{B9212691-1AF1-41AF-9DA7-6073ADDB091B}</viewName> \ 
        <View> \ 
         <Query> \ 
           <OrderBy> \ 
           <FieldRef Name='ID' Ascending='False' /> \ 
          </OrderBy> \ 
         </Query> \ 
        <RowLimit>1</RowLimit> \ 
        </View> \ 
        </GetListItems> \ 
       </soapenv:Body> \ 
      </soapenv:Envelope>"; 

     $.ajax({ 
      url: "_vti_bin/lists.asmx", 
      type: "POST", 
      dataType: "xml", 
      data: soapEnv, 
      complete: processResult, 
      contentType: "text/xml; charset=\"utf-8\"" 
     }); 
    }); 


    function processResult(xData, status) { 
     $(xData.responseXML).find("z\\:row").each(function() { 
      var liHtml = "<li>" + $(this).attr("ows_ID") + "</li>"; 
      $("#tasksUL").append(liHtml); 
     }); 
    } 


</script> 

<ul id="tasksUL"/> 

这只是返回SharePoint中视图的ID。
任何想法如何获得最高的身份证号码?

回答

0

您可以通过ID降序来为您的查询定制CAML中的行限制为1。

看看我的SPServices jQuery库,这将使这更容易。 http://SPServices.codeplex.com

顺便说一句,我相信列表本身包含最后一个ID,您可以使用GetList获取。如果你想在特定的视图中显示最高的ID,这将无济于事。

0

你SOAP是不正确,你缺少一个 “查询”:

<query><Query>...</Query></query>