Document Export Custom Templates

Requirements & Systems Portal's Document Export wizard is your go-to for whipping up editable Microsoft Word *.docx files straight from your requirements and V&V activities. You can use predefined templates or upload your own templates. The wizard is fueled by the Python-Docx-Template library, which, in turn, leverages the Jinja Templating Engine. This dynamic duo allows you to craft custom templates.

Python-Docx-Template Library

The Python-Docx-Template library is a powerful tool that extends the functionality of the Python-Docx library. It incorporates the Jinja Templating Engine, enabling dynamic content generation within your Word files. This means you can use variables, loops, and conditionals to populate your document with data on the fly. Essentially, it's like giving your Word doc a shot of espresso.

Managing Export Templates

Templates available to your Requirements & Systems Portal instance are listed on the Export templates page (  » Settings » Export templates).

  • By default, six templates are provided – three for the requirement document export and three for the V&V activity document export.

    • For more information about requirements export templates, refer to the Document Export page.

    • For more information about V&V activities export templates, refer to the Document Export page.

  • To add a new user-defined template, click the  button at the top right of the page. In the Add template window that appears, choose if the new template needs to be applied to Requirements or V&V Activities using the Applicable objects drop-down and then use the Select template region to select the template file.

    Click the  button in the dialog to add the template. It will be shown in the list on the Export templates page and can then be used in document export.

  • The file of any template can be downloaded. To do this, click the  button in the Name column of the required template and select the Download command. According to your personal browser settings, your browser will either automatically download the file to a predefined location or ask you where to store it on your hard drive.

  • A user-defined template can be overwritten with a new template file. To do this, click the  button in the Name column of the required template and select the Overwrite Template command from the menu that appears. Use the Overwrite template window that opens to define the template applicability and select the new file. Enable the I confirm I want to overwrite option and click the  button to complete the process.

Appendix – Data Object Structure of Requirement Export Templates

Three default requirement export templates are available in a Requirements & Systems Portal instance, each progressively more complex than the last. So, if you're looking to up your template game, tackling them in sequence is a smart move. Here's the lineup:

  • spec_doc.docx – this one is your straightforward, run-of-the-mill template meant to produce an identical output to the requirements Document View. It's excellent for beginners and covers simple loops and variables.

  • spec_table.docx – stepping it up a notch, this template introduces conditionals and filters. It's where things start to get spicy. It’s the Jinja version of our script-based Word template with merge fields.

  • req_verification.docx – the grandmaster of our templates. This one's rich in nested loops and conditionals, and it even incorporates tables. If you can master this, you're basically a Jedi of document templating.

Feel free to add, remove, or modify sections to fit your documentation needs better. After going through the default template files in the order given above, you might feel adventurous enough to test the limits of what you can include in your reports.

Here’s the basic structure of the object from which your requirement export templates will pull information from.

Sorting of the Fields

You can sort the requirements using the Sort function on the Jinja template document. For example, you can add |sort(attribute='identifier') where the requirements are sorted alphanumerically on the identifier column.

Example:

{% for requirement in requirements|selectattr("specification_id", "equalto", specification.id)|selectattr("group_id", "none") |sort(attribute='identifier') -%}

Custom Columns

With the current document exporter, you can export the custom column values easily. For a simple text based custom column, you can use the following generic structure:

{% for custom_field in requirement.custom_fields|selectattr(“field”, “equalto”, “Name of Custom Column”) %}{% for value in custom_field.value %}{{ value }}{% endfor %}{% endfor %}

Be sure to substitute the Name of Custom Column text with the actual name of the column indicated on the column header.

If the custom column is not a text and is a multi-selection option, the user can use the following code and update it for their use case.

{%- if requirement.custom_fields -%}
     {%- set additional_info_values = [] -%}
     {%- set category_values = [] -%}
     {%- set additional_info_custom_fields = requirement.custom_fields | selectattr('field', 'equalto', 'Additional Information') -%}
     {% for custom_field in additional_info_custom_fields -%}
      {%- set additional_info_values = additional_info_values + custom_field.value -%}
     {% endfor -%}
     {%- set category_custom_fields = requirement.custom_fields | selectattr('field', 'equalto', 'Category') -%}
     {% for custom_field in category_custom_fields -%}
           {%- set category_values = category_values + custom_field.value -%}
     {% endfor -%}
{%- set additional_info_string = additional_info_values | join(';') -%}
{%- set category_string = category_info_values | join(';') -%}
{%- endif -%}

Appendix – Data Object Structure of V&V Activity Export Templates

Here’s the basic structure of the object from which your V&V activities export templates will pull information from.

If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.

Source URL: https://www.altium365.com/documentation/requirements-systems-portal/requirements-module/document-export-custom-templates