JIRA: Export Word - Template Modifications

Richard Perez February 25, 2014

Hello,

I am attempting to modify the single-word.vm to include Due Date in the subtasks portion of the document. Here is what I have done so far with null results:

<table class="grid" cellpadding="0" cellspacing="0" border="0" width="100%">
            <tr bgcolor="#f0f0f0">
                <td>
                    <b>$i18n.getText('issue.field.key')</b><br/>
                </td>
                <td>
                    <b>$i18n.getText('issue.field.summary')</b><br/>
                </td>
                <td>
                    <b>$i18n.getText('issue.field.type')</b><br/>
                </td>
                <td>
                    <b>$i18n.getText('issue.field.status')</b><br/>
                </td>
                <td>
                    <b>$i18n.getText('issue.field.assignee')</b><br/>
                </td>
                <td>
                    <b>$i18n.getText('issue.field.duedate')</b><br/>
                </td>
            </tr>
            #foreach ($subTask in $subTasks)
                <tr>
                    <td>
                        <a href="$baseurl/browse/$textutils.htmlEncode($encoder.encode($subTask.key))">$textutils.htmlEncode($subTask.key)</a>
                    </td>
                    <td valign="top" width="25%">
                        <a href="$baseurl/browse/$textutils.htmlEncode($encoder.encode($subTask.key))">$textutils.htmlEncode($stringUtils.abbreviate($subTask.summary, 40))</a>
                    </td>
                    <td>
                        $textutils.htmlEncode($subTask.issueTypeObject.nameTranslation, false)
                    </td>
                    <td>
                        $textutils.htmlEncode($subTask.statusObject.nameTranslation, false)
                    </td>
                    <td>
                        #if ($fieldVisibility.isFieldHidden($issue.project.getLong('id'), 'assignee', $issue.issueTypeObject.id) == false)
                            #if ($subTask.assignee) $textutils.htmlEncode($subTask.assignee.displayName) #end  
                        #end
                    </td>
                    <td>
                        $textutils.htmlEncode($subTask.duedateObject.nameTranslation, false)
                    </td>
                </tr>
            #end
        </table>

issue.field.duedate renders correctly as Due Date in the header row, but duedate.Object returns a null value or blank.

Any help or pointers to a document would be greatly appreciated!

2 answers

0 votes
Andrey Markelov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

You can try free add-on: https://marketplace.atlassian.com/plugins/andreymarkelov-atlas-plugins.templator

It helps to export docx documents.

Richard Perez March 6, 2014

Hi Andrey, thanks but I would prefer to just do a simple manipulation of the Velocity template and add that dueDate variable for the subtask to export. It should be simple if I could find the right variable name to extract.

Andrey Markelov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 6, 2014

This add-on allows to use velocity or docx using same variables

Richard Perez March 6, 2014

In your app docs it only shows the variables available to task. How do I get access to the subTask variables (specifically due date)?

0 votes
mwarton
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

Hi Richard,

I haven't verified, but the subtask object is probably an Issue object documented here. If you are good with Java/velocity templates and the Atlassian framework you can probably figure out the rest from there.

As a much easier alternative, you can try our plugin Intelligent Reports. It lets you design your template directly in Microsoft Word and fill it in with issue data, subtask data and more using simple point and click rules - no scripting or API to learn.

Richard Perez February 26, 2014

The javadoc is geared toward Java (obviously), but I am working within Velocity. Is there anyway to see what is exposed to Velocity to be pulled using the $subTask variable?

<td>
     $textutils.htmlEncode($subTask.DueDateObject.nameTranslation, false)
</td>

Suggest an answer

Log in or Sign up to answer