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.

...

{{ 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. 

...

This is a custom Nunjucks filter that returns a comma-separated list of the accountIds or displayNames of the active members the members (users) of a project role. The filter can return either only active Jira members or all members including inactive Jira members. The input to the filter is the role name. The filter takes two three optional parameters:

  • projectRoleName, a String representing the project role name

  • displayNames,projectKeyOrIssue - Either the key of the project having the specified project role, or an issue object whose project has the specified project role. If not specified, the current issue’s project will be used.

  • displayNames - If true, returns display names instead of accountIds

...

  • includeInactiveUsers - If true, returns inactive users. This can only be passed via a named parameter.

Note that a maximum of 50 users per group role member will be returned.

Note: If you want to return all users - active and inactive - of the specified project role, you must used named parameters for all optional parameters. Do not mix positional parameters and named parameters!

For example:

{{ 'Administrators' | roleMembers | join(",") }} returns the accountIds of all active users of the Administrators project role

...

{{ 'Administrators' | roleMembers("TEST", true) }} returns the displayNames of all active members of the Administrators project role of the project "TEST"

{{ 'Administrators' | roleMembers(projectKeyOrIssue="TEST", displayNames=true, includeInactiveUsers=true) }} returns the displayNames of all users of the Administrators project role of the project "TEST"

searchIssues

This is a custom Nunjucks filter that runs a JQL query and returns matching issues. The filter operates on a string (the JQL query) and takes the following optional, named parameters: 

...

Note

Fields should be specified as field Keys, not field names (see Standard Jira fields and User created custom fields)


You can find more information about searching for Jira issues using JQL here: Advanced searching and Search Jira like a boss with JQL.

...

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.

For example:

Text or Multi-line text value

Template

Returns

Hi

<i>This is a test Email<i>

Regards
Radhika

{{ issue.fields.description | text2html }}

<p>Hi</p><p>&lt;i&gt;This is a test Email&lt;/i&gt;</p><p>Regards<br>Radhika</p>

Your issue has been resolved.\nPlease provide your feedback.\nThanks.

{{ "Your issue has been resolved.\nPlease provide your feedback.\nThanks." | text2html }}

<p>Your issue has been resolved.<br>Please provide your feedback.<br>Thanks.</p>

userInfo

This is a custom Nunjucks filter, which when provided with a accountId, or a user object containing a accountId field, returns the corresponding user object. You can dump the object, view its fields (in the template test result panel) and then either use the field filter to get a field value or pass the field as a parameter to the filter. 

...