With the help of Support, I got a sample to work. Following was their notes on the topic:
So, here is what I did to test it:This can be done using SUB_DOCUMENT function in a Word template (you can find details in the User Guide).
You need two templates. The first (master) will only contain a single tag with the SUB_DOCUMENT function in it, which will specify a query to get all necessary instances from the database, and the name of another Word template (detail) used for each found instance. The second template will have the body of the client letter (with all the necessary tags etc.) and a page break at the end.
To generate the combined Word document you can simply run the first template. The combined document will include the letters for each found client on separate pages (because of the line break at the end of the second template).
If you use a sort order for the query, the pages in the combined document will appear in the specified order. This could be useful for printing purposes.
Note that this works for instances specified in the query, not those already in the context. If you must do it for instances already in the context you can only generate a separate document for each instance.
1- Created BO Attributes Client.Name and Client.City
2- Created a Query called ClientsForMailMerge which selects instances of Client BO and sorts it by City. The is the sort order I want my final mail merge document to be in.
3- Create a Word doc called MailMergeDocDetail.doc which contains:
Name: <<Client.Name>>
City: <<Client.City>>
+ a Page break
4- Create a Word doc called MailMergeDriver.doc which contains:
<<SUB_DOCUMENT(`ClientsForMailMerge`,`MailMergeDetail`)>>
5- Create a Document Template called MailMergeDetail and import the Word doc from #3 above. Make this "Determined at run time".
6- Create a Document Template called MailMergeDriver and import the Word doc from #4 above. Make this "Determined at run time".
7- Now to test the BSV:
7a- Create several instances of Client
7b- Select Standard | Documents | MailMergeDriver
The merged Word document will now be ready to open.
Thanks to Support for the guidance!!
Tom