# Adding issue link information to your template

In case you want to render issue link information in your email, you must edit your email templates. Rendering issue links requires a complex processing logic. The key is `$!issue.linkCollection` that returns a `LinkCollection` object which provides methods to explore linked issues, link types, etc. if there are linked issues, otherwise null. Read more about `LinkCollection` [here](https://docs.atlassian.com/software/jira/docs/api/8.13.14/com/atlassian/jira/issue/link/LinkCollection.html).

When selecting **Linked Issues** in the Field Picker dropdown, you will get instructions on how to easily include issue link information in the template.

![](https://4173056255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY44m7ZY1jU4Arh2tzwNn%2Fuploads%2FrEdJSRMsQBJv3qxWcCy5%2Foutgoing_28.jpg?alt=media\&token=c9fe1d73-31c2-4f3c-a06c-d67c956b3e2b)

In case you want a customized display (e.g. include more attributes of the linked issues) then you can start adding these template fragments directly into your templates and customize them according to your needs.

{% hint style="warning" %}
**Important**: Jira Security is applied. The `LinkCollection` will return the linked issues as the email sender sees them. The sender may not be have the privilege to view all linked issues in Jira. If this is the case, the email may not list all linked issues either.
{% endhint %}

\
To have full control over the rendering of linked issues, insert the following code fragments into your template instead of parsing the rendering methods as above.

**Example for rendering issue link information in HTML emails**

```
#set ($lc = $!issue.linkCollection)
#if ($!lc)
 <tr valign="top">
  #if ($!isJIRA61OrLater)
     <th><strong style="font-weight:normal;color:${textSubtleColour};">Links:</strong></th>
     <td>
  #else
      <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 10px 10px 0;white-space:nowrap;"><strong style="font-weight:normal;color:${textSubtleColour};">Links:</strong></td>
      <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
  #end
    #foreach ($linkType in $lc.linkTypes)
      #set($outwardIssues = $lc.getOutwardIssues($linkType.name))
      #set($inwardIssues = $lc.getInwardIssues($linkType.name))
      #if($!outwardIssues && $!outwardIssues.size()>0)
      <dl>
        <dt><p style="font-weight: bold"></progress>$linkType.outward</p></dt>
        #foreach ($outwardLinkedIssue in $!outwardIssues)
        <dd>
            <div style="display:table;">
              <a style='color:${textLinkColour};text-decoration:none;' href='${baseurl}/browse/${outwardLinkedIssue.getKey()}'>$outwardLinkedIssue.getKey()</a>
              <span style="white-space: nowrap;">$outwardLinkedIssue.summary</span>
            </div>
        </dd>
        #end
      </dl>
        $!outwardIssues.clear()
      #end
      #if($!inwardIssues && $!inwardIssues.size()>0)
      <dl>
        <dt><p style="font-weight: bold"></progress>$linkType.inward</p></dt>
        #foreach ($inwardLinkedIssue in $!inwardIssues)
          <dd>
            <div style="display:table;">
              <a style='color:${textLinkColour};text-decoration:none;' href='${baseurl}/browse/${inwardLinkedIssue.getKey()}'>$inwardLinkedIssue.getKey()</a> <span style="white-space: nowrap;">$inwardLinkedIssue.summary</span>
            </div>
          </dd>
        #end
      </dl>
        $!inwardIssues.clear()
      #end
    #end
  </td>
</tr>
#end
```

**Example for rendering issue link information in TEXT emails**

```
#set ($lc = $!issue.linkCollection)
#if ($!lc)
Links:
#foreach ($linkType in $!lc.linkTypes)
#set($outwardIssues = $!lc.getOutwardIssues($linkType.name))
#set($inwardIssues = $!lc.getInwardIssues($linkType.name))
#if($!outwardIssues && $!outwardIssues.size()>0)
${linkType.outward}:
#foreach ($outwardLinkedIssue in $!outwardIssues)
$stringUtils.leftPad($outwardLinkedIssue.summary, $padSize): ${baseurl}/browse/${outwardLinkedIssue.getKey()}
#end
$!outwardIssues.clear()
#end
#if($!inwardIssues && $!inwardIssues.size()>0)
${linkType.inward}:
#foreach ($inwardLinkedIssue in $!inwardIssues)
$stringUtils.leftPad($inwardLinkedIssue.summary, $padSize): ${baseurl}/browse/${inwardLinkedIssue.getKey()}
#end
$!inwardIssues.clear()
#end
#end
#end
```
