Velocity context

The list of all accessible Velocity variables in nFeed

Global variables

Those variables can be used in queries, in Root element and in Columns JSON path.

TypeNameDescription
List<String>$currentCustomfieldValue

Value currently stored in the nFeed field.

Returns a list of string if the field contains many values.

User
$currentUser
Current user connected on the screen.
String
$currentUserLocale

Locale of the current user (ie: fr_FR, no_NO, ...)

Issue
$issue
Current issue
String
$userInput

Characters typed by the user in the autocomplete text box.

See the Autocomplete documentation for example usages.

Util
$util

Set of useful functions

Note about types and list of types

In our descriptions, we sometimes say that functions and variables return certain type or list of types. There is no difference in the way we handle this. This is explain in details in the Simple and multiple types section below.


Types

Date

Attributes

TypeNameDescription
String
isoDate

Iso date format 'yyyy-MM-dd'.

ex: 2015-02-22

String
isoDateTime

Iso date time format 'yyyy-MM-dd HH:mm:ss.SSS'.

ex: 2015-08-22 17:31:15.123

String
isoDateTimeZone

Iso date time zone format 'yyyy-MM-dd HH:mm:ss.SSSXXX'.

ex: 2015-08-22 17:31:15.123+02:00

Functions

Any function applicable on String is applicable on Date. In that case, the date is first converted into a String using the historical format 'EEE MMM dd HH:mm:ss zzz yyyy'.

In short, date.serialize(" ") is equivalent to date.format("EEE MMM dd HH:mm:ss zzz yyyy").serialize(" ")

Return typeNameDescription
String
format("...")

This function allows you to format your date freely, if you need a specific formatting.

Note: You can find the details about date formatting patterns in the following page: Date formatting and parsing

The ISO-8601 date format ('yyyy-MM-dd HH:mm:ss.SSSXX' ie '2015-08-22 17:55:01.123+02:00' is understood by most of databases.

Issue

Attributes

TypeNameDescription
List<Named value>
affectedVersions
Affected versions
User
assignee
Issue assignee
List<Named value>
components
Components
Date
created
Date when the issue has been created
User
creator
Issue creator

Date or

String


customfield_xxxx

A custom field value - xxxx is the field id

>> Return a List if the field contains multiple values

The return type depends on the type of the custom field. If this is a date custom field (Date or Datetime picker), the return type is a Date.

In any other case, the value is returned as a String.

String
description
Description
Date
duedate
Issue due date
String
environment
Environment
String
estimate
Estimate
List<Named value>
fixVersions
Fix versions
String
id
ID
Named value
issuetype
Issue type
String
key
Key
String
originalEstimate
Original estimate
Issue
parent
Parent of the issue (for sub-tasks only)
Named value
priority
Priority
Project
project
Project key of the the current issue
User
reporter
Issue reporter
Named value
resolution
Resolution
Date
resolutiondate
Content of the "Resolution date" field
Named value
security
Security level
Named value
status
Status
String
summary
Summary
String
timeSpent
Time spent
Date
updated
Date when the issue has been updated for the last time
String
vote
Votes count
String
watchers
Watchers count

Functions

Any function applicable on String is applicable on Issue.

Return typeNameDescription

Date or

String


get("<custom field name>")

or

get("customfield_xxx")

>> The return type depends on the type of the custom field

A custom field value - xxxx is the field id

>> Return a List if the field contains multiple values

The return type depends on the type of the custom field. If this is a date custom field (Date or Datetime picker), the return type is a Date.

In any other case, the value is returned as a String.

Named value

Attributes

By default a named value is evaluated to its name.

TypeNameDescription
String
id

Id of the value

String
name

Name of the value

Functions

Any function applicable on String is applicable on Name value.

Project

Attributes

By default, a Project is evaluated to its key.

TypeNameDescription
String
id
The project id
String
key
The project key
String
name
The project name

Functions

Any function applicable on String is applicable on Project.

The string value used in the evaluation will be the project key.

String

Functions

Return typeNameDescriptionExample
Integer
length()
Returns the String length
$issue.customfield_xxxxx.length()
> 42
String
intList()
Shortcut for $var.serialize(",")
$issue.affectVersions.id.intList() 
> 10000,10001,10002
String
prefix(<string>)

Append a string before the string

$issue.issuetype.prefix("hello ")
> hello Bug
String
replace(<reg exp>,<new str>)

Replace first string matching a regexp by another string.

The regexp can be a String

$issue.issuetype.replace("story","tale")
> User tale
String
serialize(<string>)
Join the string using a delimiter
$issue.affectVersions.name.serialize(";") 
> 1.0;1.1;1.2
String
stringList()

Append ' before and after each string and serialize them with a , separator

$issue.affectVersions.id.stringList()
> '1.0','1.1','1.2'
String
suffix(<string>)
Append a string after the string
$issue.issuetype.suffix(" world")
> Bug world
String
urlEncode()
Convert all characters to be readable in an URL
$issue.summary.urlEncode() 
> nFeed+in+a+nutshell

User

Attributes

TypeNameDescription
String
displayName
Display name of the user
String
emailAddress
Email address of the user
String
name
Name of the user
String
userName
Username of the user

Functions

Any function applicable on String is applicable on User.

The string value used in the evaluation will be the user name.

Return typeNameDescription
boolean
isInGroup(<jira group>)
Is the user member of the given group ?
boolean
isInProjectRole(<role name>,<project key>)
Does the user have the role in the project ?

Util

Functions

Return typeNameDescriptionExample

Raw text

encodeURIComponent("some text")

Convert a text to be readable in an URL parameter.

$util.encodeURIComponent("hello world ?")
> hello%20world%20%3F

Simple types and multiple types

In the descriptions above, variables and functions are said to return a specific type or a list of values of this type. This is handled exactly the same way by our API.

In short, any single value is considered being a list with a unique value. This allows to apply any function or attribute to any value without the need to check its size.

The only exception is when we convert the expression to a String value for final query evaluation. If there are many elements in a list, we only display the first one (See the examples below).


Example:


ContextExpressionResultExplanation
Issue with one fix version "1.2"$issue.fixVersions1.2N/A
Issue with two fix version "1.2" and "1.3" $issue.fixVersions1.2

When we need to evaluate a query like "SELECT * FROM XXX where version='$issue.fixVersion'", we only take the first element if there are many.

To use the other elements, you need alternate expressions (see below)

Issue with two fix version "1.2" and "1.3" $issue.fixVersions.stringList()'1.2', '1.3'This way you can write "SELECT * from XXX where version in ($issue.fixVersions.stringList())
Issue of type 'Bug'$issue.issuetypeBug
Issue of type 'Bug'$issue.issuetype.serialize("; ")Bug

As this is considered as a list of one issue type, you can apply the function serialise to it. This only has one element.

As you may also have noticed, the serialize function need a string input, and the default string evaluation for issue type (Named Value) is 'name'.

The expression is equivalent to $issue.issuetype.name.serialise("; ")