Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services &引用;“颠簸”;不更改值的SharePoint ListItem_Web Services_Sharepoint_Sharepoint 2007_Caml - Fatal编程技术网

Web services &引用;“颠簸”;不更改值的SharePoint ListItem

Web services &引用;“颠簸”;不更改值的SharePoint ListItem,web-services,sharepoint,sharepoint-2007,caml,Web Services,Sharepoint,Sharepoint 2007,Caml,首先,我使用的是: SharePoint 2007 JavaScript CAML查询 标准Web服务(_vti_bin/lists.asmx) 我正在从列表中选择一个或多个项目,具体取决于某些条件。我获取项目,并对其执行另一个条件。如果满足该条件,我希望凹凸该项,这意味着:将“修改”列更改为当前日期/时间,但不应更改任何值 这可能吗?如果是,如何做到这一点 提前谢谢 我已经不得不做同样的事情了。虽然我找不到代码,但我还是找到了当时帮助我的帖子。它是用C语言编写的,但很容易适应javascr

首先,我使用的是:

  • SharePoint 2007
  • JavaScript
  • CAML查询
  • 标准Web服务(_vti_bin/lists.asmx)
我正在从列表中选择一个或多个项目,具体取决于某些条件。我获取项目,并对其执行另一个条件。如果满足该条件,我希望凹凸该项,这意味着:将“修改”列更改为当前日期/时间,但不应更改任何值

这可能吗?如果是,如何做到这一点


提前谢谢

我已经不得不做同样的事情了。虽然我找不到代码,但我还是找到了当时帮助我的帖子。它是用C语言编写的,但很容易适应javascript:

public void Test()
        {
            string webUrl = "http://myserver";
            string listName = "docs";
            Lists.ListsSoapClient listsClient = this.GetListsClient(webUrl);

            // 1st a call to Lists.GetList - we need the list's version - it is returned in the Version attribute
            XElement listData = XElement.Parse(listsClient.GetList(listName).OuterXml);
            string listID = listData.Attribute("ID").Value;
            string version = listData.Attribute("Version").Value;
            // in the updateFields parameter of Lists.UpdateList the full schema of the fields should be provided
            string updateFields = @"<Fields>
   <Method ID='1'>
      <Field ID='{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}' ColName='tp_Modified' RowOrdinal='0' ReadOnly='FALSE' Type='DateTime' Name='Modified' DisplayName='Modified' StorageTZ='TRUE' SourceID='http://schemas.microsoft.com/sharepoint/v3' StaticName='Modified' FromBaseType='TRUE' Version='4' ShowInNewForm='FALSE' ShowInEditForm='FALSE' />
   </Method>
   <Method ID='2'>
      <Field ID='{8c06beca-0777-48f7-91c7-6da68bc07b69}' ColName='tp_Created' RowOrdinal='0' ReadOnly='FALSE' Type='DateTime' Name='Created' DisplayName='Created' StorageTZ='TRUE' SourceID='http://schemas.microsoft.com/sharepoint/v3' StaticName='Created' FromBaseType='TRUE' Version='4' ShowInNewForm='FALSE' ShowInEditForm='FALSE' />
   </Method>
</Fields>";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(updateFields);
            // Lists.UpdateList: set fields to not read-only
            XElement result = XElement.Parse(listsClient.UpdateList(listID, null, null, doc.DocumentElement, null, version).OuterXml);
            // get updated version from the result XML - for the second call of Lists.UpdateList
            version = result.Elements().Where(el => el.Name.LocalName == "ListProperties").First().Attribute("Version").Value;

            // prepare the XML for the list item update
            string updateDates = @"<Batch OnError='Continue'>
  <Method ID='M0' Cmd='Update'>
    <Field Name='ID'>1</Field>
    <Field Name='FileRef'>/docs/zt.txt</Field>
    <Field Name='Modified'>2010-04-04T22:17:00Z</Field>
    <Field Name='Created'>2010-01-01T00:05:00Z</Field>
  </Method>
</Batch>";

            doc.LoadXml(updateDates);
            // Lists.UpdateListItems: update Created & Modified
            result = XElement.Parse(listsClient.UpdateListItems(listID, doc.DocumentElement).OuterXml);

            // revert the fields' schema
            updateFields = updateFields.Replace("ReadOnly='FALSE'", "ReadOnly='TRUE'");
            doc.LoadXml(updateFields);
            // Lists.UpdateList: set fields back to read-only
            result = XElement.Parse(listsClient.UpdateList(listID, null, null, doc.DocumentElement, null, version).OuterXml);
        }
公共无效测试()
{
字符串webUrl=”http://myserver";
字符串listName=“docs”;
Lists.listsoapclient listsClient=this.GetListsClient(webUrl);
//首先调用Lists.GetList-我们需要列表的版本-它在version属性中返回
XElement listData=XElement.Parse(listsClient.GetList(listName.OuterXml));
字符串listID=listData.Attribute(“ID”).Value;
字符串版本=listData.Attribute(“版本”).Value;
//在Lists.UpdateList的updateFields参数中,应提供字段的完整架构
字符串updateFields=@”
";
XmlDocument doc=新的XmlDocument();
doc.LoadXml(updateFields);
//Lists.UpdateList:将字段设置为非只读
XElement result=XElement.Parse(listsClient.UpdateList(listID,null,null,doc.DocumentElement,null,version.OuterXml);
//从结果XML获取更新版本-用于第二次调用Lists.UpdateList
version=result.Elements().Where(el=>el.Name.LocalName==“ListProperties”).First().Attribute(“version”).Value;
//为列表项更新准备XML
字符串updateDates=@”
1.
/docs/zt.txt
2010-04-04T22:17:00Z
2010-01-01T00:05:00Z
";
doc.LoadXml(updateDates);
//Lists.UpdateListItems:创建和修改更新
结果=XElement.Parse(listsClient.UpdateListItems(listID,doc.DocumentElement).OuterXml);
//还原字段的架构
updateFields=updateFields.Replace(“ReadOnly='FALSE'”,“ReadOnly='TRUE'”);
doc.LoadXml(updateFields);
//Lists.UpdateList:将字段设置回只读
结果=XElement.Parse(listsClient.UpdateList(listID,null,null,doc.DocumentElement,null,version.OuterXml);
}
基本上,我们必须在尝试更新字段之前将其只读属性设置为false,然后在更新之后将该属性设置回true

资料来源: