...
Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
This page is about Easy Integrations for Jira DC. Using Jira Cloud? Click the Cloud button above. |
You can define parameters with Groovy Script or This documentation provides examples of how to define and use parameters in Groovy Script and Velocity Engine (Deprecated) for various scenarios within your system.
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
...
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 which 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 which 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.
...
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:
...
The EscapeTool has lots of useful methods. You can find all of the methods here.
MathTool
You can convert parameters with the MathTool, for . 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: |