Posts

Showing posts with the label CAML

Sharepoint 2013: Get all active tasks using SPSiteDataQuery for the current user (My Tasks)

My project was an intranet, a sub site monster that needed a query to show all the tasks for the current user. There were two options - recursive code (no thank you) or  SPSiteDataQuery . The key to the code is to limit the list query to the appropriate list type (see  here  for a list from Microsoft). In my case, it was "<Lists ListTemplate='107' />". Then add some simple CAML (thank you  Camldesigner ) and you are there. My final query was as follows:             SPSiteDataQuery q = new SPSiteDataQuery();             q.Webs = "<Webs Scope='SiteCollection' />";             q.Lists = "<Lists ListTemplate='107' />";             q.Query = "<Where><And><Or><Membership Type='CurrentUserGroups'><FieldRef Name='AssignedTo'/></Membership><Eq><FieldRef Name='AssignedTo'></FieldR...

Filtering list information by SharePoint group in Sharepoint 2010

My current project requires that data be filtered based on the credentials of the current user. The solution - a little magic in the view definition. In a view, you can specify the following in the 'where' clause of the CAML: <Membership Type="CurrentUserGroups">                <FieldRef Name="MyColumnToFilterData" />  </Membership> The only requirement is that the column my be of type 'Person or Group'. See here  for more information.