以编程方式更改Sharepoint 2007列表的值

时间:2011-05-09 16:59:17

标签: javascript jquery list sharepoint-2007

我的一个列表中有一个ID字段,可能会更改,需要在各个列表的列表项中进行更新。我需要知道这是否可行。我知道我可以使用C#和Sharepoint Services来完成它,但我需要通过javascript来完成它。基本上,我有5个列表,并在其中一个列表中更改客户端ID的值并单击“确定”,我需要遍历其他4个列表并更改那些列表中可能存在的项目的值客户端ID。

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:1)

我为一个政府组织工作,我们有一个大型的SharePoint 2007 Farm。我们使用jQuerySPServices库对各种SharePoint列表执行AJAX调用。

根据您的具体需要,您可以使用下面的代码示例执行一系列Web请求。

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

这是一个代码示例:

参数

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>");
    }
});