1
votes

I'm currently working with SharePoint lists and i want to get some specific listitems. The following Caml query works for me and gives me two items.

<Where>
  <In>
    <FieldRef Name='UniqueId' />
    <Values>
      <Value Type='Lookup'>E0D2E6B2-28F5-4225-8DFD-9C1FFCC8A1CQ</Value>
      <Value Type='Lookup'>EDDC5A33-38F9-4A8C-B3A8-1EED0AB98D02</Value>
    </Values>
  </In>
</Where>

When I add a Value like "test" I receive an exception. It seems that the query will only work if I have an valid UniqueId give up.

How can I make a Caml query to look for more than two UniqueId's in a list? (It is possible that an UniqueId does not exist. (They come from a separate database)

Can someone help tell me more about this?

2

2 Answers

2
votes

Use the CAML query builder for SharePoint. Whatever is listed in the builder is a valid column you can query within SharePoint. Download the builder for SharePoint 2007 here.

enter image description here

0
votes

As long as the value is a valid Guid, then you will have no problem doing what you are asking.

From your question it seems like you are trying

<Value Type='Lookup'>test</Value>

which will give you an exception.

If you want to try with an id you know you don't have, try instead with a

string.Format("<Value Type='Lookup'>{0}</Value>", new Guid());
// <Value Type='Lookup'>00000000-0000-0000-0000-000000000000</Value>

or

string.Format("<Value Type='Lookup'>{0}</Value>", Guid.NewGuid());
// <Value Type='Lookup'>eebe4177-29ff-4ece-9daa-2c293fd9aebc</Value>

And if you want to try with more than two elements, just insert more Value elements inside the Values element.