Word Templates in CB 9.3 and higher #5371368/v10820 |
Tags:
not added yet
Table of Contents
Word Reporting using Merge Fields
This feature is available starting from codeBeamer 9.3.0. Supported version is Microsoft Word 2016.
In codeBeamer 9.3 a completely new Word export functionality has been introduced. Our goal was to make customization as easy as possible by still keeping the flexibility. User can create Word templates using standard Word mechanisms without knowing about codeBeamer internals. Scripting was removed from Word template itself, although it is still possible to use scripting to cover more advanced use cases. Legacy solution was completely rewritten so customization options of legacy solution are not working with the new engine. It was replaced with new mechanisms using Word MergeFields and Bookmarks, see chapters below. Legacy solution ( See: Known issues
Default templatesFrom codeBeamer 9.3 Word export by default is working with the new export engine. If you do not select any template manually then the default template is applied which triggers the new engine.
In case of tracker item export the basic template contains summary, properties, references, associations, description. User can also choose what kind of extra content is exported for each item: comments, history or last review status. Previously this additional content was controlled by check boxes. In the new engine the template determines what kind of extra content is included. Different templates can be selected from the list box on the export dialog.
Templates appearing in the list come from two sources.
Each template context has its own sub-folder:
Legacy export solution will only be available if user uploads a legacy template. Legacy templates will not be shipped with 9.3. codeBeamer detects which kind of template the user selects or uploads (merge field based or legacy). User interface shows check boxes for extra content only in case of legacy templates. See more information on template management: Important Word Settings and ShortcutsSwitch to view field code of a particular merge field: SHIFT + F9 Switch to view field codes for all merge fields: ALT + F9 Insert a new merge field: Insert / Text / Quick parts / Field / Merge field Manage bookmarks: Insert / Links / Bookmark Make bookmarks visible: File / Options / Advanced / Show document content / Show bookmarks Make content controls visible: File / Options / Customize Ribbon / check Developer Manage content controls: Developer / Content control
Merge fieldsAll merge field names are case sensitive. In case of names consisting of multiple words then camel case is used. Eg.:
Merge field notation follows notation of codeBeamer REST API with some extensions. Properties which are available for an item are available here as well. Also there are additional data available for export purpuses. The appendix contains the available field names.
There are some exceptions here as well, following fields are not affected by field labels renaming: priority, comments, staff, closedAt.
Merge fields can be inserted from the ribbon Insert / Text / Quick parts / Field...
Merge fields can be edited using right click context menu. This will show the same window as in case of insert.
In case of insert or delete the following window appears:
Field codes for date / number / currency formatting can be entered when inserting or editing a merge field, by clicking the button Field Codes on the bottom of the window.
Formatting fieldsBy default, formatting defined on merge fields is applied to the replaced content during export. Font, size, color, alignment, styles all received by the content which is rendered into the field. Wiki fields are an exception from above behaviour. Wiki fields have its own formatting inside codeBeamer and that formatting can not be overwritten by Word template. Content of wiki fields should look like (more or less) the same as on web regardless of formatting of mergefield in the template. Wiki fields are rendered as html then inserted into the Word document. Currently supported ways of using wiki/html mergefields in templates are:
Formatting date fields using field codes: Define Date and Numeric Formats for Mail Merge Fields
CommentsIf "item.commentsPlace" is inside the template then item comments are added to the document as Word comments, anchored to this point. This field should be put into a separate line in the template like it is done in case of default templates.
Hyperlink fieldsSee: Available merge fieldsYou can find available merge fields here:
From codeBeamer 9.4 you can generate this listing dynamically which includes all fields including custom fields:
Multi value fields can be printed simply without bookmark loops too. In this case only the names will be shown, separated by comma. eg.: "item.assignedTo" When there is a need for more complex look, then bookmark loops can be used with specific fields/properties. Please see next chapter.
Bookmark blocksWhen you are exporting a multi value field like a choice list then using only merge fields is not enough. A loop must be defined in the template by adding bookmarks. When you are editing the template in Word select Insert / Links / Bookmark on the ribbon. This will show you a small window where you can view and manage existing bookmarks in the document. By entering a name and clicking Add you can create a new bookmark on the current selection. In the below example the bookmark "loop_item_upstream" is created on the table row which is selected. By selecting a block of document and creating a bookmark on it you are defining which part of document should be the body of the respective loop.
Squared brackets show the begin and end of the bookmarked block. This is not visible by default, you can switch it on at File / Options / Advanced / Show document content / Show bookmarks.
Name of bookmark blocks must match to respective merge field names.
If you define a custom field with label "Related Bugs" then
All bookmark names are case sensitive like merge field names.
Currently bookmark loop detection is relying on the location of the bookmarkStart tag. If bookmark starts inside a table then particular table row will be looped (referred as table row loop from now). If bookmark start outside a table then included paragraphs/tables will be looped (referred as paragraph loop from now).
When copying content which includes bookmarks then bookmarks will not be copied because of duplication. Bookmark names have to be unique in the document. User has to create a new bookmark by altering the name of the original bookmark.
When using the same loop multiple times in a document, then user has to add some postfix to alter the name of bookmark. eg.: loop_item_downstream2, loop_item_downstreamPostfix Underscore used to determine levels, so it cannot be used in the postfix. eg.: loop_item_downstream_postfix => will not work
Eg.: Referring onto "item.upstream.name" inside "loop_item_downstream" will result in error.
Limitations:
Rendering table fields of trackers
Columns of table fields can be accessed by their index eg.:
Above fields must be inside a bookmark called "loop_item_tableName". See example below. See also default Test Case template for an example table "testSteps": template-test-cases-base.docx
Please note: For table fields to work in Word export "Row numbers" option must be checked on the table field in the tracker configuration.
Links to codeBeamer ResourcesLinks to codeBeamer resources can appear in Word export documents in two different ways. If you check "Generate absolute links" then all link will point to the codeBeamer instance where export was initiated. See screen below.
If above checkbox is left unchecked, then those links which point onto items present in the currently exported document will become internal links pointing onto bookmarks inside the document. This is a feature which helps in offline work, when codeBeamer instance is not accessible.
Heading stylesIf a line is formatted with a heading style in the template then the exported document will also use this heading style. You can see this in case of headings in standard template. Usage of heading levels in case of item hierarchies start from the level defined in template (starting from version codeBeamer 9.5). Eg. if <<item.name>> is formatted with Heading 2 then top-level items will have Heading 2 and their children will have Heading 3 and their children Heading 4 etc. Heading styles will follow as the hierarchy goes deeper.
If you want to change the numbering and start at a different level eg. at 1.1. instead of 1.1.1. then in Word you can adjust which heading belongs to which list level. Right click on number / Adjust List Indents... / More >>
Velocity macrosLocation of velocity macro library: tomcat/webapps/cb/config/templates/export/mergefields.vm Velocity macro names are all lower case as the examples show: eg.: field_item_downstream_name eg.: property_name
To evaluate value of a field a velocity macro is called based on the field name. This provides an extra customization option for the user where some kind of text transformation can be implemented. There are two type of macros:
New merge fields can be defined by creating new velocity macros.
Custom HyperlinksProperties starting with "url" will be a hyperlink
Accessible variables in the Velocity contextItem data is available in the form of a JSON /cb/rest/item/<item-id> Name of a particular merge field selects a specific path in this tree. This path consists of a couple of nodes or objects. All of these selected objects are accessible from the velocity context.
Conditional formattingConditional formatting can be achieved by using multiple merge fields each of which matching to appropriate result of a condition. The default test run template contains a good example:
"item.testCaseRuns.result.name" is formatted/colored differently depending on the value of it. To make this work you have to introduce new merge fields by creating velocity macros. During rendering only one of the merge fields will have value, the others will be rendered empty. See example merge fields below: #macro(field_item_testcaseruns_result_namepassed) #set($result = $leaf.get("name").getAsString()) #if($result == "Passed") $result.toUpperCase() #end #end #macro(field_item_testcaseruns_result_namefailed) #set($result = $leaf.get("name").getAsString()) #if($result == "Failed") $result.toUpperCase() #end #end #macro(field_item_testcaseruns_result_nameelse) #set($result = $leaf.get("name").getAsString()) #if($result != "Passed" && $result != "Failed") $result.toUpperCase() #end #end #macro(field_item_testcaseruns_notrunyet) #set($result = $leaf.get("result")) ## if result is null #if("$!result" == "") NOT RUN YET #end #end By default empty fields receive a "--" value so this would be a problem if "--" would appear for all merge fields. This can be avoided by adding new entries to existing macro called "not_available". This provides the value which is shown for empty fields. ## empty fields are populated with some n/a value to clearly show something is not available ## if a merge field result remains empty during merging then this macro is run to populate some value #macro(not_available) ## Some specific merge fields don't need n/a value but should be actually empty. ## - A notification is present or not, it is never missing. ## - Chapter number is also not missing, but it is present or not. ## - Conditional fields also use this behaviour. ## From multiple fields only one will get value, others remain empty. #if( $fieldName != "item_changenotif" && $fieldName != "item_chapter" && $fieldName != "item_testcaseruns_result_namepassed" && $fieldName != "item_testcaseruns_result_namefailed" && $fieldName != "item_testcaseruns_result_nameelse" && $fieldName != "item_testcaseruns_notrunyet" && $fieldName != "item_assocout_to_urlkeyid" && $fieldName != "item_assocout_urlurl") $!naValueFromTemplateParameters #end
System Admin Configuration of Word ExportEach Word export job runs as a new process separate from codeBeamer. This process can be configured as below.
Callback URL The callback URL is where codeBeamer application is accessible for external export application process. This is detected automatically by default. If server is behind Apache
Configuration can be done at System Admin / Application Configuration:
You can see relevant entries below: "applicationApi" : { "callbackUrl" : "http://localhost:8080/cb" }, "wordExport" : { "debugLogging" : false, "jvmArguments" : "-Xmx3G", "maxParallelProcesses" : 3, "restLoaderPageSize" : 50, "timeoutSeconds" : 3600 }, "interactive" : { "maxAllowedWordExportItemCount" : 5000 } |
Fast Links
![]() codebeamer Overview codebeamer Knowledge Base Services by Intland Software |
This website stores cookies on your computer. These cookies are used to improve your browsing experience, constantly optimize the functionality and content of our website, and help us understand your interests and provide more personalized services to you, both on this website and through other media. With your permission, we and our partners may use precise geolocation data and identification through device scanning. You may click accept to consent to our and our partners’ processing as described above. Please be aware that some processing of your personal data may not require your consent, but you have a right to object to such processing. By using our website, you acknowledge this notice of our cookie practices. By accepting and continuing to browse this site, you agree to this use. Your preferences will apply to this website only.
Note that user-behavior analytics are being captured on this server to improve the Codebeamer user experience.