JIRA: Export Word - Template Modifications

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

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.

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>

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.

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

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

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

84 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you