/
Velocity Script Examples

Velocity Script Examples

Summary

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

Storing catch email address information in issues

Velocity reference

 

Description

Velocity reference

 

Description

$catchEmailAddress

IEmailAndPersonal (jemhc-api 1.3.513 API)

Contains the email address $catchEmailAddress.getEmailAddress() and (optionally) the personal $catchEmailAddress.getPersonal() of the catch email address found in the processed email

$matchingRecipient

API reference for Java Platform, Standard Edition

Shorthand for $catchEmailAddress.getEmailAddress() (see above).

$matchingCatchEmailAddress

API reference for Java Platform, Standard Edition

A string representing the configuration responsible for finding the catch email address. Depending on what was configured in the profile, this could be a static address or a regular expression.

When using this custom field value later (e.g. in templates):

Setting a Date field 1 day in the future

To demonstrate this, here is a walk through:

Create a Velocity Custom Field Default

Default custom field values are set in Project Mapping and resolved when an email is processed.

  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 date field, select Velocity and when you want the field to be updated.

  4. Enter the following script: 

     

    $longVal is defined as a variable, (with the value of the current time in milliseconds, plus 24(hours)*60(minutes)*60(seconds)*1000(millis) = 8640000), then the $dateFormatter is in charge of rendering the date generated from $jemhDateUtils.createDate

     

Screen will look like: