SharePoint,如何使用 where 子句从 Web 服务更新列表项?
我有一个场景,我需要更新列表项,但我不知道列表项的内部 ID - 因此以下内容对我不起作用:
batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
"<Field Name='ID'>" + id + "</Field>" +
"<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field></Method>";
相反,我在列表中有另一个名为 ProcessID 的字段:
所以我想要更新 ProcessID = X 的交付状态
这是否可以使用 SharePoint Web 服务实现。
我想到的一个解决方案是首先根据 ProcessID 对 ID 进行选择 - 然后根据此 ID 进行更新,但这似乎是一个疯狂的解决方案,MOSS CAML 的发明者肯定会提供一种更新列表的方法item 通过 where 子句的某种方式,或者使用另一个字段进行过滤,而不仅仅是普通的旧 ID?
谢谢
I have a scenario where I need to update a list item, but I don't know the internal ID of the list item - hence the following won't work for me:
batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
"<Field Name='ID'>" + id + "</Field>" +
"<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field></Method>";
Instead I have another field in the list called ProcessID:
So I would like to update the delivery status where ProcessID = X
Is this possible using SharePoint web services.
One solution I was thinking of is to first do a select for the ID based on the ProcessID - then update based on this ID, but this seems like a crazy solution, surely the inventors of MOSS CAML would have provided a way to update a list item by some means of a where clause, or using another field for filtration rather than just plain old ID?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信你可以在哪里进行更新。您需要获取与给定 ProcessID 匹配的所有项目,才能获取每个单独的项目 ID。
由于您使用的是 Web 服务,因此提高效率的一种方法是确保在执行选择时设置 ViewFields 属性,以便将其限制为仅您感兴趣的列(在本例中为 ID)。
例子:
I don't believe you can do an UPDATE WHERE. You will need to get all the items matching your given ProcessID in order to get each of the individual item IDs.
Since you're using web services, one way to make this more efficient is to make sure you set the ViewFields property when you perform your select in order to limit it to only the columns you are interested in (in this case, ID).
Example: