开发者

How to update a sharepoint list item via web services using a where clause?

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜