SP2010 Query Agenda items from Meeting Workspace does not return values

I think that might be interesting. If you query a list – it doesn’t matter what kind of list – it returns the desired values… normally… BUT there is one exception. If you use the template Meeting Workspace in SharePoint with multiple dates and you would like to get all agenda items for the next meeting after the upcoming, your script won’t return any values. It doesn’t matter if you are using

  • the query in Nintex Workflow
  • c#
  • powershell

The reason for this is simple but not nice. The meeting workspace uses an instance id for each meeting. As default it returns the current meeting items or the items from upcoming event. For quering the next meeting after the upcoming you should make sure to set the instance id right. I added as example my script:



$MeetingWorkspaceUrl = "http://server/sites/sitecollection/MeetingWorkspaceUrl/default.aspx?InstanceID=2"
$CurrentInstancID = $MeetingWorkspaceUrl.Split("=")[1]

$web = Get-SPWeb $MeetingWorkspaceUrl.Substring(0,$MeetingWorkspaceUrl.lastIndexOf("/"))
$List = $web.Lists["Agenda"]
$ListItem = $List.Items | ? {$_["Instance ID"] -eq $CurrentInstancID }

$spQuery = New-Object Microsoft.SharePoint.SPQuery
$spQuery.MeetingInstanceId = $CurrentInstancID
$spQuery.Query = "<where><eq><fieldref Name='Title'></fieldref><value Type='Text'>Test</value></eq></where>"

$ListItems = $List.GetItems($spQuery)
foreach ($Item in $ListItems)
{
$Item["Title"] = "Test2"
$Item.Update()
}


The line 9 is the important one. By default it is set to -3 which means that it only queries the upcoming event. But i want to query the next event, so i set it to my own instance id which is “2”. In the query you can now select all items which has “Text” in Title field or which has a special ItemId.

Hope this helps you.

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.