Versions Compared

Key

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

Summary

Custom field values can be set on a per-project and/or per-rule basis in your JEMHCloud profile, where they are called Custom field defaults.

...

Click the little cog  beside the project mapping you've elected. Go into the Issue tab and click the Edit button found towards the top right. Scroll down until you see the Custom field defaults section.

Setting a Static value

The simplest way to set a custom field is by passing a static text-format value. Find the desired custom field from the list. Ensure that the drop-down at the end of the row is set to Text, and enter a value to be used for this project mapping/rule.

...

Once a value has been entered, you can then select when this value should be set (issue creation, issue comment, both). Finally, submit the form to save your changes.

Setting a Dynamic value

To set a dynamic value this will require either a Velocity script or a JavaScript Script to gather and set the relevant value.

To set a dynamic value this will require a Velocity script to gather the value. When the script is parsed it will result in whatever value is present in the template after rendering being set as the value for the Custom Field.

Using Velocity

Once the Velocity script is parsed it will result in whatever value is present in the template after rendering being set as the value for the Custom Field. For more information about Velocity see: https://velocity.apache.org/engine/1.7/user-guide.html#what-is-velocity

Velocity Context

When you create a dynamic Custom Field Default, you can make use of special variables found in the ‘context’, see them through:

...

  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 Velocity and when you want the field to be updated e.g. On Create/Comment.

    Image Added
  4. Enter the relevant script within the text-box

See the following page for some example Velocity Scripts: Velocity Script Examples

Using JavaScript

This allows you create Custom JavaScript that will evaluate and set the relevant values to the Custom Field.

Info

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

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

setValue(value)

Sets the value for this Custom Field

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.

    Image Added
  4. Enter the relevant script within the text-box

See the following page for some JavaScript examples: JavaScript examples

Testing JavaScript Custom Field Default

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

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

    Image Added

When are custom field values applied?

...