...
You can define parameters with Groovy Script or Velocity Engine (Deprecated).
...
title | Important Changes to Easy Integrations' Pricing |
---|---|
type | Info |
...
Button handy | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Button handy | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
This page is about Easy Integrations for Jira DC. Using Jira Cloud? Click the Cloud button above. |
This documentation provides examples of how to define and use parameters in Groovy Script and Velocity Engine (Deprecated) for various scenarios within your system.
If you want to use the new value of a field (which is changed via the transition screen) and you also want to update a custom field value, you should use $transitionIssue
and place the REST Caller Service post function before the Update change history and store the issue in the database post function.
On this page:
|
---|
Groovy Script
Code example:
Code Block | ||
---|---|---|
|
...
def parameters = [:]
parameters["assignee"] = issue.assignee
parameters["reporter"] = issue.reporter
def userManager = ComponentAccessor.getUserManager()
parameters["userDisplayName"] = userManager.getUserByName("someUserName").getDisplayName()
def cf = customFieldManager.getCustomFieldObject("customfield_xxxxx")
def price = issue.getCustomFieldValue(cf)
parameters["price"] = (null != price) ? price : "No price defined"
return parameters |
...
Velocity Engine
User
assignee = $issue.assignee or {{issue.assignee}}
reporter = $issue.reporter or {{issue.reporter}}
displayName = $user.displayName
userDisplayName = $ComponentAccessor.getUserManager().getUserByName("someUser").getDisplayName()
Date
Issue date fields:
updated = $issue.updated
created = $issue.created
Formatted date:
formattedDate = $DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format($issue.created)
Custom Field Values
productName = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11100'))
price = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11102'))
Utils
jsonEscapedString = $Utils.jsonEscape($issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_12500')))
Comment
Getting a comment
...
that has passed through the transition:
comment = $comment
Field
...
changes in
...
transition
$issue.get..
methods might return the old or new values within a transition depending on the location of the post function.
Assume that we have a transition
...
that uses a transition screen in which customfield_10123 can be changed.
If the REST Service Caller post function is BEFORE the
...
Update change history for an issue and store the issue in the database
...
post function, then
$issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123'))
call would return the old value.If the REST Service Caller post function is AFTER the
...
Update change history for an issue and store the issue in the database
...
post function, then
$issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123'))
call would return the new value.
But, what if we need both values?
You can use transientIssue
for the updated fields within the transition instead of issue
productName = $transientIssue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123'))
Line
...
breaks
You can remove line breaks with the replaceAll() method:
description = $issue.description.replaceAll("\n", "")
Render
...
options
You can render parameters in HTML or Plain Text:
HTML render → $wikiUtils.wikiToHtml($comment)
Plain Text render → $wikiUtils.wikiToText($comment)
EscapeTool
You can escape parameters with the EscapeTool, for example:
issueSummary = $escape.html($issue.summary)
The EscapeTool has lots of useful methods. You can find all of the methods here.
MathTool
...
You can convert parameters with the MathTool
...
. For example:
price = $mathUtils.toInteger($issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11100')))
The MathTool has lots of useful methods. You can find all of the methods here.
Warning |
---|
...
Empty/Null valuesSimply add |
...
for example, Null safe usage: |