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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

152 views 1 17
Join discussion

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