Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
Note

In Closed Beta - not yet publicly available

Summary

Below are some example Velocity Scripts that can be used when setting a Dynamic Custom Field Default.

...

API

Notes

message.getBody()

Get body content of email. Not available for preprocessing task.

message.getSubject()

Gets the Subject content of email.

message.getAllHeaders()

Get all headers of a message.

message.getHeader(name)

Get value of a message header

Parameters

  • name the name of the header to get

issue

If the email being processed has been associated with is commenting on an existing issue, this contains the issue data. Format then this context will contain the field values for the related issue. Allowing for this data to be used within the Script. Format used is as per the Get Issue response from the Jira REST API.

Note: This is only available within the Script Custom Field default and the Script Field Processor.

print(str)

Adds output that is recorded during execution and shown in the processing report.

Parameters

  • str (String) the string to be recorded

RegExp

Searches within string values for matching content.RegExp - JavaScript | MDN

setValue(value)

Sets the value for this Custom Field

...

Code Block
setValue("FieldValue");

Example Scripts

Using the Issue Context

...

when commenting

Info

Currently cannot be used at edit time. A email/Test Case will need to be processed to test the script

When Commenting on issues you are able to use the issue to get values from the issue. for example getting the issue Key, Reporter or any Custom Field. Below are some examples on how to extract specific values.

Note: The issue context does not apply when creating an issue. This means that the issue context will return “null”.

Getting the Issue Key

Code Block
issue.key

...

Getting a Custom Field Value

In order to get a the value from a Custom Field you will need to define the Custom Field Id for that the relevant field as the field name is not stored within the Issue context. Also this ensures This is to ensure that the value is gathered from the correct Field.

...

Code Block
issue.fields.reporter.displayName

Example Scripts

Using Regex to extract a specific value from body and set as the field value

...