Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel
panelIconIdatlassian-info
panelIcon:info:
bgColor#F4F5F7

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.

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:

Table of Contents
minLevel1
maxLevel6
outlinefalse
styledefault
typelist
printabletrue

Groovy Script

Code example:

Code Block
languagegroovy
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 MathToolfor . 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 values

Simply add ! after the $ sign if the result can be empty or null. Otherwise, it will display the command as is (

...

for example, $issue.assignee).

Null safe usage: $!issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_xx')).