Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

CAML Query GroupBy not working

$
0
0

Hi,

i have a list with several items. I want to group by a column called "Dept".

For example i have these records: 

NameDepartments

JohnIT
MarkIT
LisaHR
MattFI
MarkFI
JohnIT
SamIT
JaneIT
JohnHR

John has 3 records:

JohnIT
JohnIT
JohnHR

I want to filter for "John" an the result should be (distinct by the column departmen):

IT
HR

I tried the following Query with list.GetItems(query):

	query.Query = "<GroupBy Collapse='TRUE'>" & _"<FieldRef Name='Salary' />" & _"</GroupBy>" & _"<Where>" & _"<Eq>" & _"<FieldRef Name='Dept' />" & _"<Value Type='Lookup'>FI</Value>" & _"</Eq>" & _"</Where>"

and the result is (i tried with veiwfields only with one column, too):

IT
IT
HR

but i want to have

IT
HR

I built a view with a group by statement and a filter based on my needs and copied after that the QUERY from theSharePoint Manager 2010 but this also didnt work!

What is wrong here?


Best regards,
Yavuz B.

My Sharepoint and Enterprise 2.0 Blog http://www.bogazci.com |Microsoft Sharepoint Resources & Blog List


Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>