This is a follow-up to a question someone asked during GURUpalooza at Lotusphere 2007. The scenario described is that after upgrading to a new version of Domino and applying a new mail database template, some users lost folders. This isn't an uncommon problem, and I posted a snippet of code in response to a similar question on the developerWorks Lotus forum. Gregg Eldred picked that up and blogged about it, but it is still coming up so I thought I would do a more formal write up, and clean up the code.
The reason the above happens is simple: if there is no template specified for the database and users create folders, the Prohibit design refresh from replacing or modifying option is not set. If there is a template defined, it is. What's odd is that when you create a mail database for someone the standard process sets the template name. Sometimes this gets wiped out, and I honestly don't understand why. I just know that in my own environment, with extremely technophobic users, it has happened a number of times.
What this means is that when the database is updated from its template, any folders a user created while the template was blank will be deleted. The documents are left in the database, though, and will show up in All Documents. You just have no way of knowing what folder they should be in and it's a royal mess.
Below is a snippet of code that will take care of this for you. Here's a brief rundown of what it is doing:
- Open the Domino Directory
- Loop through all the Person documents to get the mail files
- Compare all the folders in each person's mail database with the template you specify
- If the folder exists in the template, it clears the Prohibit design refresh flag. This allows a design refresh to update anything that is in the template. If the folder is not in the template but it is in the user's mail file, set the Prohibit design refresh flag, which will prevent the design refresh from deleting the user's folders.
provided by Julian Robichaux at nsftools.com.