Assume following requirement: you want to have a list of the exported Work Items at the beginning of the Word document exported from codeBeamer. The goal is a table something like this:
The final custom template is here, check and improve this: CB:/displayDocument/ListItems-template.docx?doc_id=1412160
Here is how to do that:
- First download the default Word template, and save it locally. This is the template we'll customize.
- Next find the block which renders the Tracker name. That is nearly at the beginning. Select that block by clicking on the left "handle" to select the whole block, and copy it to the clipboard. Click on handle:
Please note - in certain Word versions you might need to select this part to be included in a bigger selected area in case of having issues with rendering.
- Next go upwards and paste this block. The block being copied here is a special "Content Control" of Word, and such blocks can contain Velocity scripts which are evaluated by codeBeamer during export.
- Next we need to write a custom Velocity script which renders the exported items in a table. The script will be this - you can easily find this by looking at the attached example template as that has red text !
## an example of how to add a table of exported items at the beginning of the document
<table>
<thead>
<tr><th>Requirement Name</th><th>Status</th></tr>
</thead>
#set($itemIterator = ${items.iterator()})
#foreach ($item in $itemIterator)
<tr><td><a href=”#item_${item.id}”>${item.name}</a></td><td>${item.status.name}</td></tr>
#end
</table>
As you see this script renders an HTML table. The ${items} collection contains all exported Work items, and the script will print out an HTML row for each item, which contains the item's name and its status as well.
That's it! If you execute the Word export using this template that will contain the Work items' list at the beginning of the document...
As extra feature the requirement table at the beginning contains links, which can be clicked on so that Word will jump to the desired requirement below. This works by using HTML anchors and links to anchors inside the document.