2011-05-09 106 views
1

我在其中一個列表中有一個ID字段,它可能會更改並需要在各種列表中的列表項中進行更新。我需要知道這是否可能。我知道我可以使用C#和Sharepoint Services完成它,但我需要通過javascript來完成。基本上,我有5個列表,並在其中一個列表中更改客戶端ID的值,然後單擊「確定」,我需要遍歷其他4個列表並更改該列表中可能存在的任何項目的值客戶端ID。以編程方式更改Sharepoint 2007列表的值

任何援助非常感謝!

回答

1

我爲一個政府組織工作,我們有一個大型的SharePoint 2007農場。我們使用jQuerySPServices庫來對各種SharePoint列表執行AJAX調用。

爲了您的具體需要,您可以使用類似下面的代碼示例來執行一系列Web請求。

下面是更新SharePoint列表的API:
http://spservices.codeplex.com/wikipage?title=UpdateListItems&referringTitle=Lists

這裏有一個代碼示例:

PARAMS

batchCmd: "Update", 
valuepairs: 
    [["Title", "New Title Value"], 
    ["Body", "Here is a the new text for the body column."]], ID: 1234, 

XML

<Batch OnError='Continue'> 
    <Method ID='1' Cmd='Update'> 
    <Field Name='Title'>New Title Value</Field> 
    <Field Name='Body'>Here is a the new text for the body column.</Field> 
    <Field Name='ID'>1234</Field> 
    </Method> 
</Batch> 

JS

$(divId).html(waitMessage).SPServices({ 
    operation: "UpdateListItems", 
    listName: testList, 
    ID: ID, 
    valuepairs: [["Title", now]], 
    completefunc: function (xData, Status) { 
     var out = $().SPServices.SPDebugXMLHttpResult({ 
      node: xData.responseXML, 
      outputId: divId 
     }); 
     $(divId).html("").append("<b>This is the output from the UpdateListItems operation:</b>" + out); 
     $(divId).append("<b>Refresh to see the change in the list above.</b>"); 
    } 
}); 
相關問題