0

I'm trying to get the items from a child list (a lookup list i suppose, i'm new in SharePoint development) that are related to their items in the parent list. For brevity, lets call them list A for parent and list B for child. So in general, list A has at most 4 to 5 child items from list B, and it can sometimes have no item from B at all. I'm using the amazingly useful Camlex.Net library for creating the caml queries. This is the caml that i'm creating via camlex, very basic:

<Query>
  <Where>
    <Eq>
      <FieldRef Name="VisitSummary" LookupId="True" />
      <Value Type="Lookup">1</Value>
    </Eq>
  </Where>
</Query>

The problem is that when item 1 in list A (like in the xml above) doesn't have items in list B, so SharePoint returns all the items in list B, which is not desirable at all. When list A does have child items in B, it works well, it gets only the related items.
Is there a way to tell SharePoint to return some other value, perhaps null or whatever instead of all the items in the child list?

thanks,
ashilon

ashilon
  • 1,791
  • 3
  • 24
  • 41
  • 1
    Try to surround the query with `` tag see [this](https://sharepoint.stackexchange.com/questions/110925/caml-query-returns-all-items-instead-of-one) and [this](https://stackoverflow.com/questions/19675644/sharepoint-use-sp-camlquery-in-jquery) – Max Jan 07 '19 at 10:02
  • This seems to do the trick! I wonder why doesn't Camlex.Net doesn't add it itself. Anyways Max thanks a lot, how do I mark your comment as the answer? – ashilon Jan 07 '19 at 10:55
  • Below I posted the answer – Max Jan 07 '19 at 11:23

1 Answers1

1

You must surrond the query with the <view> tag.

See this question on stackoverflow and this on stackexchange

Max
  • 6,821
  • 3
  • 43
  • 59