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

落爺英雄遲暮 提交于 2019-12-06 06:59:50

问题


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.


回答1:


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.




回答2:


I think the default view of the list displays only the upcoming meeting list items, and not the meeting list items in the past.

If you don't specify the view on which you run your CAML query, it will retrieve all the items from the default view. Use the All Items view (All Events view if it is a calendar) instead of the default view, also set the SPQuery.ExpandRecurrence property to true.



来源:https://stackoverflow.com/questions/963864/in-a-meeting-workspace-get-all-agenda-items-from-a-list-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!