Tuesday, January 30, 2007

Using Custom Forms for data entry with Outlook/Exchange Public Folders

An interesting learning experience today regarding the use of custom forms in Outlook.

I was attempting to customise folder in our Public Folders, for use with customer contact details. The bigger picture is that our back office user registration system, has to update a public contacts folder used by sales guys and management to track support renewals and just generally log activity with our customers.

The logical starting point for the sychronisation with the back office system, was to ensure all the fields that the users require, actually exist against contacts in the public folder. Thus began my customised Outlook forms adventure.

First tip, "you need to make sure the appropriate users have ownership rights on that public folder in order to add the new fields" - this is best achieved using the Exchange System Manager - on the Exchange server.

Then, it was down to business, creating a new form for data entry in this public folder. I started with some very minor changes, just to "spike" the whole solution to ensure it was going to work the way I expected - good move. I created a new form and published it into the Public Folder. Then, from the Tools menu I could select that form to do some design work on (Tools/Foms/Design a Form) then choose your Public Folder in the "Look In" drop down list. Select the form you just published there and open it.

Once your are accessing the form, in design mode, but selected from the one published to your public folder, the custom fields added to that folder, will be available for you to choose in the Field Selector - "User Defined Fields in Folder" selected in drop down list on top of the Field Chooser.

So, you add a few fields, publish the form back into the same public folder, then go to that public folder to try it out.

Firstly, you'll need to make sure the form is assicaited with the folder. "Right click" the folder, go to Properties, then the "Forms" tab, if the form is not showing in the list, click Manage. You should see the form in the list. Closing this form sometime seems to refresh your forms list on the properties dialog, if indeed, the form was missing in the first place. The other setting that must be made here is on the General Tab. Make sure you select your new form in the "When posting to this folder, use:" field.

Now setting this much up achieves only half the job. Any new items "posted" to this folder will make use of your new form. Any existing ones will not. Why? The answer turns out to be to do with the Message Class of existing and new messages.

New messages will automatically take on the message class associated with your new form - old messages will have the message class of the old, original form used to create them, and therefore continue to use that form, when you open them for editing.

This brings me back to another trap I fell into back at the start. When you first create your new form, (Tools/Forms/Design a Form) make sure you inherit from the appropriate type of form, in the Standard Forms Library. New items, added using your new form, will take on the class of that form, plus the name of your form - so in my case where I was using a Contacts Public Folder the message class of my new items became, IPM.Contact.AllUsers. This message class is the key to getting older/existing items in your folder to use you new form.

You can display the message class in a list view in your folder. Using the Field Chooser, find "Message Class" (in the All Post Items category) and add it to your view. You can then see the message class assigned to all items. Quickly adding a new one will show you what your form is using and you'll know what the older ones need to be changed to.

Now, changing the items seems to be easier said than done as well. At this point I must hand much of the credit over to this post on the Windows IT Pro site. This is what explained to me the importance of the Message Class and also directed me towards the tools to change it.

The tools I used turned out to be the macro in the Word Document found on the Microsoft site - here but upon reflection, would've been quite easy to write myself. Anyway, now, all items in my Public Contacts folder have the correct Message Class, and now use my newly customised form. Now it's time to go to town on customisations to that form, and also some cool new views of that folder.