Text functions

How to use

Smart Fields in Automation for Jira also support a number of string manipulation functions.  This works with any 'text' type field such as summary, description, and text custom fields.  You can also use string manipulation functions on issue sub-attributes, such as the {{issue.reporter.displayName}}.

Supported functions

Note

All of the following examples assume summary field value of Hello World!.

abbreviate(int maxLength)

Abbreviates a String using ellipses. This will turn "Now is the time for all good men" into "Now is the time for..." See StringUtils.abbreviate(int) for full details.

{{issue.summary.abbreviate(8)}} -> Hello...

chartAt(int index)

See String.charAt(int) for full details.

{{issue.summary.charAt(2)}} -> e

capitalize()

See StringUtils.capitalize(String) for full details.

{{issue.summary.capitalize()}} -> Hello world!

concat(String str)

See String.concat(String) for full details.

{{issue.summary.concat(" World!")}} -> Hello World! World!

endsWith(String str)

See String.endsWith(String) for full details.

{{issue.summary.endsWith("World!")}} -> true

htmlEncode()

Encodes strings to allow them to be included in HTML content. E.g. outgoing emails

{{issue.summary.htmlEncode}} -> See Encoding below.

indexOf(String str)

See String.indexOf(String) for full details.

{{issue.summary.indexOf("Wo")}} -> 6

isAlpha()

Checks if the String contains only Unicode letters. See StringUtils.isAlpha() for full details.

{{issue.summary.isAlpha()}} -> true

isAlphanumeric()

Checks if the String contains only Unicode letters or digits. See StringUtils.isAlphanumeric() for full details.

{{issue.summary.isAlphanumeric()}} -> true

isEmpty()

Checks to see if the string is empty - "". See StringUtils.isEmpty() for full details.

{{issue.summary.isEmpty()}} -> false

isNotEmpty()

Checks to see if the string is not empty - "". See StringUtils.isNotEmpty() for full details.

{{issue.summary.isNotEmpty()}} -> true

isNumeric()

Checks if the String contains only digits. See StringUtils.isNumeric() for full details.

{{issue.summary.isNumeric()}} -> false

jsonEncode()

Encodes strings to allow them to be included in JSON calls. E.g. outgoing webhook

{{issue.summary.jsonEncode}} -> See Encoding below.

lastIndexOf(String str)

See String.lastIndexOf(String) for full details.

{{issue.summary.lastIndexOf("o")}} -> 7

left(int length)

Returns the number of chars specified from the left of the string. See StringUtils.left(int) for full details.

{{issue.summary.left(5)}} -> Hello

leftPad(int length, String pad)

Adds the specified string until the source is of the length specified See StringUtils.leftPad(int, String) for full details.

{{issue.summary.leftPad(14, "-")}} -> --Hello World!

length()

See String.length() for full details.

{{issue.summary.length()}} -> 12

match()

Performs a regular expression search and will return the first (and only one) matching regular expression group. The underlying implementation is based on Java's Pattern class and uses Matcher.find() to find matches. If multiple matches are found, they will be returned as a collection that can be iterated. This can be used to find a single pattern match (e.g. extract a version number from the issue description) or to match multiple patterns (e.g. extract all e-mail addresses from an issue comment).

{{issue.summary.match(".*(lo).*")}} -> lo
{{issue.summary.match(".*(o).*")}}  -> [o, o]

quote()

Escapes the smart value into a literal string expression that can be used in a regular expression match using Pattern.quote().

{{issue.summary.quote()}} -> \QHello(.*)World!\E

remove(String remove)

See StringUtils.remove(String) for full details.

{{issue.summary.remove("l")}} -> Heo Word!

replace(String target, String replacement)

Replaces all literal string matches with the replacement. See String.replace(String, String) for full details.

{{issue.summary. replace("Hello","Goodbye")}} -> Goodbye World!

replaceAll(String regex, String replacement)

Performs a regular expression search and replaces any match with the replacement. $1 can be used to access a matching group in the replacement. See String.replaceAll(String, String) for full details.

{{issue.summary.replaceAll("(lo)","xx$1yy"}} -> Helxxloyy World!

reverse()

See StringUtils.reverse() for full details.

{{issue.summary.reverse()}} -> !dlroW elloH

right(int length)

Returns the number of chars specified from the right of the string. See StringUtils.right(int) for full details.

{{issue.summary.right(6)}} -> World!

rightPad(int length, String pad)

Adds the specified string until the source is of the length specified. See StringUtils.rightPad(int, String) for full details.

{{issue.summary.
rightPadPad(14,"-")}} -> Hello World!--

substring(int start)

See StringUtils.substring(int) for full details.

{{issue.summary.substring(7)}} -> orld!

substring(int start, int end)

See StringUtils.substring(int, int) for full details.

{{issue.summary.substring(1,3)}} -> el

substringAfter( String separator)

Returns the string after the first occurrence of the given separator. See StringUtils.substringAfter(String) for full details.

{{issue.summary. substringAfter("W")}} -> orld!

substringAfterLast(String separator)

Returns the string after the last occurrence of the given separator. See StringUtils. substringAfterLast(String) for full details.

{{issue.summary. substringAfterLast("o")}} -> rld!

substringBefore(String separator)

Returns the string before the first occurrence of the given separator. See StringUtils. substringBefore(String) for full details.

{{issue.summary. substringBefore("W")}} -> Hello

substringBeforeLast(String separator)

Returns the string before the last occurrence of the given separator. See StringUtils. substringBeforeLast(String) for full details.

{{issue.summary. substringBeforeLast("o")}} -> Hello W

substringBetween(String open, String close)

Returns the string between the given parameters. See StringUtils. substringBetween(String, String) for full details.

{{issue.summary. substringBetween("e","d")}} -> llo Worl

split(String separator)

See String.split(String) for full details.

{{issue.summary.split(" ").first}} -> Hello

startsWith(String str)

See String.startsWith(String) for full details.

{{issue.summary. startsWith("World!")}} -> false

toLowerCase()

See String.toLowerCase() for full details.

{{issue.summary.toLowerCase()}} -> hello world!

toUpperCase()

See String.toUpperCase() for full details.

{{issue.summary.toUpperCase(}}}} -> HELLO WORLD!

trim()

Removes any whitespace at the beginning or end of the value. See String.trim() for full details.

{{issue.summary.trim()}} -> Hello World!

urlEncode()

Encodes strings to allow them to be included as a URL param. E.g. link in an email

{{issue.summary.urlEncode}} -> See Encoding below.

xmlEncode()

Encodes strings to allow them to be included in XML data. E.g. outgoing webhook

{{issue.summary.xmlEncode}} -> See Encoding below.

Chaining functions

Functions can also be chained so you can do something like:

{{issue.summary.toLowerCase().substring(0, 10).concat("!!")}}

Displaying default values

You can also display text, when a value of a field is blank by using the ^ symbol.

{{^issue.My Text Field}}Only prints out when blank{{/}}

Encoding

When integrating with other systems or sending emails you may need to encode the text in a special way to comply with standards or to not break things. For example, if you are sending an HTML email, you may need to encode an issue's description as HTML. This will escape certain characters to comply with the HTML Specs.

Html encoding

HTML encoding is useful for emails and exporting HTML pages. For example Waiting for R&D would be encoded as Waiting for R&D.

// Function
{{#htmlEncode}}{{issue.status.name}}{{/}}

// Inline version
{{issue.status.name.htmlEncode}} 

Json encoding

Useful when sending Outgoing webhooks as JSON. For example "Hello World" would be encoded as \"Hello World\".

// Function
{{#jsonEncode}}{{issue.summary}}{{/}}

// Inline version
{{issue.summary.jsonEncode}}

URL encoding

Useful when sending creating links in emails. For example Hello & World would be encoded as Hello%20%26%20World.

// Function
{{#urlEncode}}{{issue.summary}}{{/}}

// Inline version
{{issue.summary.urlEncode}}

Xml encoding

Useful when sending Outgoing webhooks as XML. For example Hello & World would be encoded as Hello & World.

// Function
{{#xmlEncode}}{{issue.description}}{{/}}

// Inline function
{{issue.description.xmlEncode}}