Menu

Expressions

Timothy Anyona

Expressions

Expressions enable including of dynamic content in certain fields. Fields that can have expressions include

  • Job fixed file name
  • Job email subject
  • Job email message
  • Job sub directory
  • Parameter values and default values
  • Report source
  • Report short description
  • Report fileName JSON option

Field Expressions

Field expressions substitute certain known items. Field expressions start with f[ and end with ]f. Field expression names are case sensitive.

Username

You can use a field expression to substitute the username of the currently logged in user, or for jobs, the job owner. Use the value f[username]f to substitute the username.

Dates

You can substitute the current date by using the expression f[date]f. This will output the current date in yyyy-MM-dd format e.g. 2017-11-10. You can use the expression f[datetime]f to substitute the current date and time in yyyy-MM-dd HH:mm:ss.SSS format e.g. 2017-11-10 11:25:21.045. Both date and datetime field expressions can also specify a different date other that "now" and additionaly specify the output format, output format locale, input format and input format locale. These additional items are specified separated by | i.e f[date field name|date specification|output format|output format locale|input format|input format locale]f.

The date specification component can be the string "today" to specify today's date with the time component as zero, it can be the string "now" to specify the current date and time, or a date string in certain numeric formats e.g. yyyy-MM-dd or yyyy-MM-dd HH:mm:ss. In addition one can have simple date arithmetic by having a string starting with "add" and then specifying an offset from the current date e.g. add days 1 or add months -1. The duration offsets that can be specified include days, weeks, months, years, hours, minutes, seconds, milliseconds.

The output format component can be used to specify the desired output format of the resulting date using Java SimpleDateFormat syntax. Additionaly, a locale can be specified to define the locale which should be used with the given output format.

If the date specification is not in one of the common numeric formats, the format it is in can be specified in the input format section, and if required, the input format locale can be specified.

Groovy Expressions

Groovy code can be used to provide dynamic text. Groovy expressions start with g[ and end with ]g e.g. g[1+1]g. You can have longer code which includes imports etc. Groovy code is by default passed through a sandbox so if a SecurityException is thrown, the relevant class needs to be added to the WEB-INF\groovy-whitelist.txt file, or alternatively, turn off the sandbox in the WEB-INF\art-custom-settings.json file.

Parameter values

You can include parameter values as part of a groovy expression with a call like param1.value. If it is an LOV parameter and you would like to output the display value, you can use syntax like param1.textValue. An example full expression would be g[param1.textValue]g.


Related

Discussion: Format DateTime parameter in Report Short Description?