Search code examples
vstooutlook-addin

How can I initialise a form region when the assign task button is clicked?


I have a custom form region defined for Tasks and TaskRequestItems. When I create a task the Form Region is initialised correctly but when I click the "Assign Task" button, the item is updated to a TaskRequestItem and my form region disappears. If in Outlook I click New Items > More Items > Task Request then the form region appears correctly on the TaskRequestItem.

Does anyone know why the form region disappears on conversion of Task to TaskRequestItem or whether there is a way to trigger the form region initialisation when the "Assign Task" button is clicked?

Thanks in advance


Solution

  • You need to check the message class of the item shown and then add it to the list of supported items of your form region. You can do that by adding a new attribute to the form region class with the message class you are interested in.

    Every item contains a Message Class field; this field contains the name of the form that Outlook provides to view and edit the item. For example, a contact item has a default message class of "IPM.Contact". If you create a custom form called "Customer", the Message Class field of items using that form will contain "IPM.Contact.Customer". The message class of all Outlook items always begins with "IPM". The second part of the message class denotes the type of Outlook form that the form is based on. The third portion of the message class is present only if the form is a customized version of a standard Outlook form.

    There are two ways to associate a form region with a message class:

    Use the New Outlook Form Region wizard.

    On the final page of the New Outlook Form Region wizard, you can select standard message classes and type the names of custom message classes that you want to associate with the form region.

    To include one or more custom message classes, type their names in the Which custom message classes will display this form region? box.

    Apply class attributes

    The first attribute associates the form region with a standard message class for a mail message form. The second attribute associates the form region with a custom message class named IPM.Task.Contoso.

    [Microsoft.Office.Tools.Outlook.FormRegionMessageClass
        (Microsoft.Office.Tools.Outlook.FormRegionMessageClassAttribute.Note)]
    [Microsoft.Office.Tools.Outlook.FormRegionMessageClass
        ("IPM.Task.Contoso")]
    

    You may find the following pages helpful:

    Associate a form region with an Outlook message class

    Create Outlook form regions