This documentation is archived and is not being maintained.

Rename a Contact Group

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Renaming a contact group involves casting the IUccGroup interface to its IUccCategoryInstance interface so that a publishable copy of the interface can be created. You update the Name property and publish the publishable copy of the category instance.

Bb804214.note(en-us,office.12).gifNote:
Each property of the contact group you change requires an individual publishing operation. For example, you cannot set the Name property of a group in the same publishing operation you set the Contacts property.

Renaming a contact group involves the following steps:

  • Create a publication manager object by casting an IUccEndpoint object into an IUccPublicationManager object. The publication manager is responsible for creating a publishable category instance object and publication object. You create the publication manager once for the endpoint and use it for each publishing operation you perform.
  • Get a category instance representing the group to be added by casting the IUccGroup interface into an IUccCategoryInstance.
  • Create a publishable category instance by calling CreatePublishableCategoryInstance.
  • Cast the publishable category to the IUccGroup interface to gain access to the property being updated and set the property value as required.
  • Set the publication operation on the publishable category to be renamed by filling the PublicationOperation property using a Unified Communications Client API enumeration value UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD.
  • Create a publication object by calling CreatePublication and casting the returned value to the IUccPublication interface.
  • Register for publication events to catch the asynchronous response to this publication request.
  • Add the IUccCategoryInstance created earlier to the publication with a call into AddPublishableCategoryInstance.
  • Publish the renamed group by calling the Publish method on the publication object. In this example, the optional operation context is not supplied with the request.
  • Handle the asynchronous group event raised with the publication response from Office Communications Server.
  • Handle the asynchronous publish event raised with the publication response from Office Communications Server.
public void RenameGroup(IUccGroup group, string groupName)
{
    try
    {
        IUccPublicationManager pubMgr = endpoint as IUccPublicationManager;
        //QI the IUccGroup to its IUccCategoryInstance
        IUccCategoryInstance cat = group as IUccCategoryInstance;

        //Create new publishable category based on the original cat
        IUccCategoryInstance pCat = cat.CreatePublishableCategoryInstance();

        //QI the publishable category to IUccGroup to gain access
        //to the group properties
        IUccGroup iGroup = pCat as IUccGroup;
        iGroup.Name = groupName;

        //Set publication operation type for this category
        pCat.PublicationOperation = UCC_PUBLICATION_OPERATION_TYPE.UCCPOT_ADD;

        //create publication object and register for pub events
        IUccPublication pub = pubMgr.CreatePublication() as IUccPublication;
        UCC_Advise<_IUccPublicationEvent>(pub, this);

        //add the publishable category instance created before 
        //to publish it.
        pub.AddPublishableCategoryInstance(pCat);
        pub.Publish(null);
    }
    catch (COMException ex)
    {
        Utilities.ReportError(ex.ToString());
    }
}
void _IUccGroupEvents.OnNameChanged(
                      IUccGroup pEventSource,
                      Object pEventData)
{
   ...
}
void _IUccPublicationEvent.OnPublish(
                           IUccPublication pEventSource,
                           IUccOperationProgressEvent pEventData)
{
   ...
}
Show: