Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Filters are essentially functions that can be applied to variables. Filters are called with a pipe operator (|) and can take arguments. This document details custom Nunjucks filters created for JMWE.

...

{{ issue.fields.comment.comments | last | commentProperty("sd.public.comment") | field("internal") }} returns true if the latest comment of the issue is a Jira Service Desk "internal" comment.

...

{{ issue.fields.reporter | emailAddress}} returns the email address of the Reporter. 

{{ issue.fields.Approvers | emailAddress}} returns an array of the emails of the issue's Approvers.

...

{{issue | epic("status") | field("fields.status.name") returns the name of the status of the Epic.

...

{% set stories = issue | epic("key") | stories("status") %} creates a variable 'stories' that holds all stories of the parent Epic of the current issue (i.e. the current issue and all its sibling stories), limiting the fields returned for each story.

...

{{ "Carter" | findUsers | dump(2) }} returns an array of users and dumps it in "pretty" JSON format, using 2 spaces as indentation.

{{ "john@acme.com" | findUsers | first | field("accountId") }} returns the accountId of the Jira user whose email address is john@acme.com .

{{ issue.fields['Custom text field'] | findUsers | first | field("emailAddress") }} returns the email Address of the first user that matches the string in the custom text field.

...

{{ issue | issueProperty("a.property") }} returns the value of the "a.property" property of the current issue

...

{% set myObj = '{"f1":"val"}' | JSONparse %}
{{ myObj.f1 }} outputs val

linkedIssues

linkedIssues is a custom Nunjucks filter that returns an array of the issues linked to the current issue, optionally specifying one or more issue link type name(s) as they appear on the issue.

...

{{ issue | linkedIssues('blocks', ['status','summary']) }} returns an array of issues linked with the 'blocks' link type, with only the Summary and Status fields. 

...

{{ issue | membersOfInitiative("assignee") | last | field("fields.assignee.accountId") }} returns the accountId of the user the last epic belonging to the Initiative is assigned to. 

{{ issue | membersOfInitiative("key") | join(",","key") }} returns the issuekey of all epics of the Initiative, separated by a comma.

...

{{ "Shared Team" | optionID("customfield_14589") }} returns the numerical ID of the Tempo team whose name is "Shared Team"

Note

Note that this filter can be slow. When setting the field to a constant value, it is, therefore, preferable to directly input the numerical ID in the post-function configuration, which you will get by running the Nunjucks expression above in the Nunjucks Tester.

organizationID

The organizationID filter is a custom Nunjucks filter that returns the Jira Service Desk Organization numerical ID of one or more Organization(s). The filter is applied to a string representing an Organization name, or to an array of Organization names.

...

remoteLinks is a custom Nunjucks filter that returns an array of all remote links (for example a Confluence page or an issue in another Jira instance) from the issue. It applies to an issue object or an issue key. 

...

For example: 

{{ issue | stories }} returns an array of the stories associated with the Epic. 

...

{{ issue | stories("key") | join(",","key") }} returns the issuekey of all stories of the Epic, separated by a comma.

...

This is a custom Nunjucks filter that converts a multi-line text value to html, as expected in the html body in the Email Issue post-function. The newlines are converted to paragraphs and html tags are escaped. The input for the filter is either a multi-line text or a multi-line text field.

...