Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to query a list in an eventreceiver through properties.List.GetItems (in the itemadding event). The field I'm filtering on is a 'Person or Group' field. But the query always returns all items instead of just the ones having the user I provided.

I'm using following code:

I've already checked following post: link but this didn't resolve my problem.

the query I use is:

<Where>
        <Eq><FieldRef Name='Gebruiker' LookupId='TRUE' /><Value Type='Integer'>{0}</Value></Eq></Where>

I Also tried:

<Where><Eq><FieldRef Name='Gebruiker' LookupId='TRUE' /><Value Type='Lookup'>{0}</Value></Eq></Where>

Any help is welcome

share|improve this question

1 Answer 1

I found it in the meanwhile :)

When I passed the query as a string to the GetItems function it wasn't working correctly. However when I create a SPQuery-object, pass the query (the string) to the Query property of that object and then pass that object to the GetItems function it works correctly :) .

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.