Friday, May 16, 2008

Configuration documents - 'Best of Breeds' solution

Reading the assono.de web site I came across a tip from Thomas Bahn. As I'm not as steady in german, I had ot use the Babelfish to translate from german to english. Much can be said about the translation but I'll leave that alone for now. On to the tip...

It's a 'Best of Breeds' Solution approach to configuration documents or setup documents.

Profiledocuments has been much used to create and access database\application setup information. This solution is fast and the code to write and access the data is clean and slick.

However profiledocument has been prone to errors when it comes to replication and ofcourse is cached when loaded. Especially when using profile documents to hold counter, sequnencenumber, workflow status and such, this will be a problem.

The solution is simple but elegant:

1. Create the setup/configuration document using normal document creation methods like @Command[Compose];"MyConfigDoc")

2. In the QuerySave or PostSave add code to create a Profile document containing only the setup documents UniversalID.

@SetProfileField("ConfigUNID" ; "ConfigUNID" ; @Text(@DocumentUniqueID) )

Now You haver Your profile document with the UNID that references the Configuration document. Extracting the data from the document is as easy as this:

ConfigDocID := @GetProfileField ("ConfigUNID";"ConfigUNID");
@GetDocField (ConfigDocID; "Config_CustomerEmail")

This is not much different than the direct use of ProfileDocument:
@GetProfileField ("MyConfigDoc";"Config_CustomerEmail")

Notice that You only need one line of extra code in the 'Best of Breeds' Solution.

This example only shows implementation using Formula, LotusScript should be just as easy to implement.