Search code examples
sharepointmosswindows-sharepoint-services

In a meeting workspace get all agenda items from a list programmatically


I want to get all items from a specific list in recurring meeting workspace. I tried to execute the following CAML:

<Query>
   <Where>
      <IsNotNull>
         <FieldRef Name='ID' />
      </IsNotNull>
   </Where>
</Query>

But it only displays data for the upcoming meeting.

However when I open list, from actions menu I can choose to display data from all meetings. That makes me think it is possible. I know I can convert the list to series items so they appear in all meetings, but it is not that I want.


Solution

  • Yeehaaw!

    Finally I found a solution! SPQuery class has a property MeetingInstanceId, which one you can assign a value of a specific InstanceID (for example 20090615 for 15 June 2009 items) or to query all items you must assign it SPMeeting.SpecialInstance enum value (don't forget to cast it to int).

    Then you just execute your query to get items from whatever workspace you want.

    Oh, and don't forget

    using Microsoft.SharePoint.Meetings;
    

    Or you can ommit using SPMeeting.SPecialInstance, but use integeres directly from -3 to 0

    Sample code:

    using(SPSite site = new SPSite(<enter your workspace url>))
    using (SPWeb web = site.OpenWeb())
    {              
        SPQuery query = new SPQuery();
        query.MeetingInstanceId = (int)SPMeeting.SpecialInstance.AllButSeries;
        query.Query = @"<Query>
                           <Where>
                              <IsNotNull>
                                 <FieldRef Name='ID' />
                              </IsNotNull>
                           </Where>
                        </Query>";
    
        SPList list = web.Lists[<enter your list>];
        foreach (SPListItem item in list.GetItems(query))
        {
            Console.WriteLine(item[item.Fields.GetFieldByInternalName("Title").Id]);
        }
    }
    

    It took so much time for this to find. Probably not too much info on the net for this issue or I didn't choose the right keywords, but anyway credit to this source for getting in the first place for keywords "get all list items sharepoint workspace recurring".

    I hope this helps others.