0
votes

I've an issue with a caml query - to select a sharepoint item where the field "Title" is of a specific value...

  Dim camlQuery As New CamlQuery()
  camlQuery.ViewXml = "<Query><where><Contains><FieldRef Name='Title'/><Value Type='Text'>" & orderno & "</value></Contains></where></Query>"

Problem is this returns all the items in the list. Orderno will be a guid, so it is unique. I've read a few questions on here that have had a few suggestions but nothing has worked.

I've tried replacing

  <eq> 

with

  <contains>

But that's no use. The start of the query used to read

  <View><Query>      

And I've changed it but that's had no effect either. As far as I can see the query looks OK - not sure why this is going wrong.

Edit: Also, this is using microsoft.sharepoint.client so .items() isn't available on the list object.

2

2 Answers

1
votes

The CAML in your question has syntax problems because CAML is case sensitive.

<where> should be <Where>, </where> should be </Where>, and </value> should be </Value>. (Similary, <eq> should be <Eq> and <contains> should be <Contains>.)

You should wrap the entire CAML query in <View></View> tags when setting it as the value for the .ViewXml property. If you want to add a <RowLimit> element, it would come after the closing </Query> tag but before the closing </View> tag.

1
votes

Use Caml Query Builder in this case. it will help you to get expected result and one more important point here is you need to use "View" tag in Client Side Object model when you try to fetch List Items.

It might help you :)