0 out of 1 rated this helpful - Rate this topic

How to: Remove a Meeting from a Meeting Workspace

Published: May 2010

Meetings you create through an events list are not canceled or deleted when the associated event is deleted, and it is not possible to cancel or delete a meeting from a Meeting Workspace site through the user interface. This programming task shows how you can remove a meeting from a Meeting Workspace by creating a console application that uses methods of the Lists and Meetings Web services.

To remove a meeting from a Meeting Workspace

  1. Create a console application in Microsoft Visual Studio as described in How to: Create a Console Application.

  2. Add Web references for both the Lists and Meetings Web services as follows:

    1. Right-click References in Solution Explorer, and then click Add Service Reference.

    2. In the Add Service Reference dialog box, click Advanced, and in the Service Reference Settings dialog box, click Add Web Reference.

    3. In the URL box of the Add Web Reference dialog box, type the URL for the Web service, including the site to which the service applies and the virtual directory for Web services, such as the following:

      http://Server/sites/Site_Name/_vti_bin/Lists.asmx

    4. Click Add Reference.

    5. Repeat this procedure to add a reference to Meetings.asmx for the Meetings Web service.

  3. Add a using directive (Imports in Visual Basic) for the System.Xml namespace to Class1.cs.

  4. Add the following code example to the Main method, which starts by instantiating the Lists and Meetings Web services, authenticating the current user for use of both services, and then gathering input from the user that specifies which meeting to delete.

    Dim listObj As New Web_Reference.Lists()
    listObj.Credentials = System.Net.CredentialCache.DefaultCredentials
    
    'Get Meeting Workspace URL.
    Console.Write("Enter the URL of the Meeting Workspace: ")
    Dim baseURL As String = Console.ReadLine()
    
    'Set URL properties for both objects.
    listObj.Url = baseURL + "/_vti_bin/lists.asmx"
    meetObj.Url = baseURL + "/_vti_bin/meetings.asmx"
    
    'Get meeting InstanceID.
    Console.Write("Enter the InstanceID of the meeting: ")
    Dim InstanceID As String = Console.ReadLine()
    
    Dim xmlDoc As New XmlDocument()
    
    Dim ndQuery As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "")
    Dim ndViewFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "")
    Dim ndQueryOptions As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "")
    
    'Create Query to filter based on the InstanceID provided.
    ndQuery.InnerXml = "<Where><Eq><FieldRef Name=""ID""/> + 
         "<Value Type=""Counter""> + InstanceID + "</Value></Eq></Where>"
    
    Try
       'Call GetListItems Web service to get meeting UID.
       Dim ndResult As XmlNode = listObj.GetListItems("Meeting Series", "", ndQuery, ndViewFields, "0", ndQueryOptions)
       Dim MainNode As XmlNode = ndResult.ChildNodes.Item(1)
       MainNode = MainNode.ChildNodes.Item(1)
       Dim eventUID As XmlNode = MainNode.Attributes.GetNamedItem("ows_EventUID")
       Dim UID As String = eventUID.InnerText
       
       'Call RemoveMeeting Web service to cancel meeting.
       'NOTE: You might need to increase the sequence number depending
       'on how many updates have already been made to the meeting.
       meetObj.RemoveMeeting(0, UID, 0, DateTime.Now, True)
       
       Console.WriteLine("Meeting canceled successfully.")
       
       Catch ex As System.Web.Services.Protocols.SoapException
          Console.WriteLine(("Message:" + ControlChars.Lf + 
          ex.Message + ControlChars.Lf + "Detail:" + ControlChars.Lf + 
          ex.Detail.InnerText + ControlChars.Lf + "StackTrace:" + 
          ControlChars.Lf + ex.StackTrace))
    End Try
    

    /*Create necessary objects and set credentials.*/
    Web_Reference.Meetings meetObj = 
       new Web_Reference_Folder_Name.Meetings();
    meetObj.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
    Web_Reference.Lists listObj = 
       new Web_Reference.Lists();
    listObj.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
    /*Get Meeting Workspace URL.*/
    Console.Write("Enter the URL of the Meeting Workspace: ");
    string baseURL = Console.ReadLine();
    
    /*Set URL properties for both objects.*/
    listObj.Url = baseURL + "/_vti_bin/lists.asmx";
    meetObj.Url = baseURL + "/_vti_bin/meetings.asmx";
    
    /*Get meeting InstanceID.*/
    Console.Write("Enter the InstanceID of the meeting: ");
    string InstanceID = Console.ReadLine();
    
    XmlDocument xmlDoc = new XmlDocument();
    
    XmlNode ndQuery = 
       xmlDoc.CreateNode(XmlNodeType.Element,"Query", "");
    XmlNode ndViewFields = 
       xmlDoc.CreateNode(XmlNodeType.Element,"ViewFields","");
    XmlNode ndQueryOptions = 
       xmlDoc.CreateNode(XmlNodeType.Element,"QueryOptions","");
    
    // Create query to filter based on the InstanceID provided.
    ndQuery.InnerXml = 
       @"<Where><Eq><FieldRef Name=""ID""/><Value Type=""Counter"">" +
       InstanceID + "</Value></Eq></Where>";
    
    try
    {
       /*Call GetListItems Web service to get meeting UID.*/
       XmlNode ndResult = 
          listObj.GetListItems("Meeting Series", "", ndQuery, 
          ndViewFields, "0", ndQueryOptions);
       XmlNode MainNode = ndResult.ChildNodes.Item(1);
       MainNode = MainNode.ChildNodes.Item(1);
       XmlNode eventUID = 
          MainNode.Attributes.GetNamedItem("ows_EventUID");
       string UID = eventUID.InnerText;
    
       /*Call RemoveMeeting Web service to cancel meeting.
       NOTE: You might need to increase the sequence number depending
       on how many updates have already been made to the meeting.*/
       meetObj.RemoveMeeting(0, UID, 0, DateTime.Now, true);
    
       Console.WriteLine("Meeting canceled successfully.");
    }
    catch (System.Web.Services.Protocols.SoapException ex)
    {
       Console.WriteLine("Message:\n" + ex.Message + "\nDetail:\n" + 
          ex.Detail.InnerText + "\nStackTrace:\n" + ex.StackTrace);
    }
    

    The example creates an XmlDocument object, which is used to create nodes for constructing the parameters passed to the GetListItems method. The GetListItems(String, String, XmlNode, XmlNode, String, XmlNode, String) method returns the item from the site's Meeting Series list whose identifier (ID) is equal to the instance ID that is specified by the user. Collaborative Application Markup Language (CAML) is used to construct the query. The ows_EventUID attribute that is returned through the GetListItems method contains the GUID that identifies the Meeting Workspace site to be deleted, which is passed to the RemoveMeeting method.

  5. On the Debug menu, click Start Debugging to test the application.

Date

Description

Reason

May 2010

Initial publication

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
need some help
Hey guys in msdn i have this problem i copy this code on vs 2010 and in vb and c# it send me an error on this statement $0$0 $0 $0 $0 listObj.GetListItems("Meeting Series", "", ndQuery, ndViewFields, "0", ndQueryOptions);$0 $0the error is that listobj.getlistitems need 6 options and need webid where do i get that value? i would appreciate any help ty $0 $0
Isn't this fixed yet?
Seems to me that this is one of those tasks that should have been included within the project. A site admin should be able to clean up orphaned meetings with out having to run code from the command line on the server. OK ... I'm grumpy about this. Please throw us a bone MS and fix this in the next update.
The example ist not working
1) the method: GetListItems needs also at last parameter a WebId as string
after i fixed this to get the id from sitedata.asmx, the method 1) return nothing..
if i put in the InstanceID as integer 1 or 2 or 3.. and also as dateId from url, for example: 20110518 (the id in caml query is IMHO the list item id, but the poor user never is able to read listitem from SP-UI)