如何使用 where 子句通过 Web 服务更新共享点列表项?

发布于 2024-09-03 13:11:30 字数 563 浏览 2 评论 0原文

我想使用 SharePoint 更新列表项,并且正在努力寻找 1 个合适的 CAML 示例。

这就是我想要做的,在 SQL 中我的查询看起来像这样

update [table] set field='value' where fieldID = id;

所以这意味着我在列表中有 1 个项目,我想根据该列表项的 ID 更新 1 个字段。

我已经尝试过这个,但它不起作用:

batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
            "<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field>" +
            "<Where><Eq><FieldRef Name='ID' /><Value Type='Text'>" + id + "</Value></Eq></Where></Method>";

I would like to update a list item using SharePoint and am stuggling to find 1 decent CAML example.

Here is what I want to do, in SQL my query would look something like this

update [table] set field='value' where fieldID = id;

so this would mean I have 1 item in a list I would like to update 1 field on given the ID of that listitem.

I've tried this, but it doesn't work:

batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
            "<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field>" +
            "<Where><Eq><FieldRef Name='ID' /><Value Type='Text'>" + id + "</Value></Eq></Where></Method>";

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如梦亦如幻 2024-09-10 13:11:30

我将为社区添加这个答案,尽管它可能无法回答您的所有问题。

 batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
                "<Field Name='ID'>" + id + "</Field>" + 
            "<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field></Method>";

您指定的第一个字段似乎是 where 子句。

我不知道你将如何对此进行任何高级过滤(不或排除或在子句或范围中)。但希望这些基本信息有所帮助。

I'll add this answer for the community, although it might not answer all your questions.

 batchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
                "<Field Name='ID'>" + id + "</Field>" + 
            "<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field></Method>";

It seems the first field you specify is the where clause.

I have no idea how you would do any advanced filtering with this (nots or exclusions or in clauses or ranges). But hope this basic info helps.

恏ㄋ傷疤忘ㄋ疼 2024-09-10 13:11:30

您不需要使用 where 子句来更新列表项。

atchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
            "<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field>" +
            "<FieldRef Name='ID' /><Value Type='Text'>" + id + "</Value></Method>";

您唯一需要做的就是提供上面的 ID。

You don't need use the where clause to update a list item.

atchElement.InnerXml = "<Method ID='1' Cmd='Update'>" +
            "<Field Name='DeliveryStatus'>" + newStatus.ToString() + "</Field>" +
            "<FieldRef Name='ID' /><Value Type='Text'>" + id + "</Value></Method>";

The only think you need do is to provide the ID like above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文