Using JavaScript to set custom fields

Using JavaScript to set custom fields

User-provided JavaScript code is run, allowing custom logic to be used when setting a custom field. See more JavaScript examples.

Setting the Value

To set the relevant value on the Custom Field you would need to include setValue(fieldValue) within the script once the value has been extracted.

JavaScript Context

API

Notes

API

Notes

setValue(fieldValue)

Sets the value for this Custom Field.

Parameters

  • fieldValue the field value to set

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 an existing issue, this contains the issue data. Format is as per the Get Issue response from the Jira REST API.

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

Steps to set create a JavaScript Custom Field Default

  1. Go to Profile > Project Mapping > Issue > Edit

  2. Under CUSTOM FIELDS DEFAULTS you will see the available custom fields for the project mapping's project.

  3. Find your custom field, select JavaScript and when you want the field to be updated e.g. On Create/Comment.

  4. Enter the relevant script within the text-box

Testing JavaScript Custom Field Default

  1. Once the relevant Script has been configured, select a Test Case within the Select Box and Press Run.

  2. Once processed there will be an output of the Results. Allowing you to review if the correct outcome has occurred. For example below.