Example - Setting a Date field 1 day in the future
Create a new Custom Field Default
When the Field Value type is set to Velocity Scripted Value, the "Velocity Context" is expandable, showing the contents of the JEMH Velocity Context, with hyperlinks to online Javadoc.
Showing the velocity context
The icon pops up the velocity context available, including (for now) some static values that would be supplied during real processing
Example content:
Specific Email related values
SINCE 2.4.21
context variable | Data Type | Description |
---|---|---|
message | javax.mail.Message | the raw message object |
subject | java.lang.String | the Subject text |
$jemhUtils.getCatchEmailAddress().getAddress() | java.lang.String | The Mailbox catchEmailAddress |
toAddresses | javax.mail.InternetAddress[] | the to: addressees |
ccAddresses | javax.mail.InternetAddress[] | the cc: addressees |
bccAddresses | javax.mail.InternetAddress[] | the bcc: addressees (don't expect many here!) |
allAddresses | javax.mail.InternetAddress[] | all addressees |
body | java.lang.String | the post processed (html > markup) content – since JEMH 2.7.36 for Jira 7.10.x |
Add the Velocity code
$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 used with a specific style, based on the date generated from $jemhDateUtils.createDate:
#set($longVal = $currentMillis.longValue() + 86400000 ) $dateFormatter.withStyle($dateTimeStyle.DATE).format($jemhDateUtils.createDate($longVal))
Preview the output
Press the blue preview button to render the Velocity code in the Preview window.
After Submitting the form, the Custom Field Defaults section view will show the rendered Velocity values as applicable (here showing the next days date, 15/Oct/16 in a valid format):
Now, issues created, will have the Custom Field Test Date set with a dynamically generated value of 29/Mar/15, which is correctly parsed by JIRA and results in issues being created with the appropriate value: