---
title: "Parameter usage examples"
canonical: "https://support.appfire.com/space/EI4J/11206752/Parameter%20usage%20examples"
format: markdown
---
> Macro (aura-html)

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.

## Groovy Script

<span style="color: #000000">Code example:</span>

```groovy
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

- <span style="color: #000000">assignee = $issue.assignee or {{issue.assignee}}</span>
- <span style="color: #000000">reporter = $issue.reporter or {{issue.reporter}}</span>
- <span style="color: #000000">displayName = $user.displayName</span>
- <span style="color: #000000">userDisplayName = $ComponentAccessor.getUserManager().getUserByName("someUser").getDisplayName() </span>

### Date

<span style="color: #000000">Issue date fields:</span>

- <span style="color: #000000">updated = $issue.updated</span>
- <span style="color: #000000">created = $issue.created</span>

<span style="color: #000000">Formatted date:</span>

- <span style="color: #000000">formattedDate = $DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format($issue.created)</span>

### Custom Field Values

- <span style="color: #000000">productName = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11100'))</span>
- <span style="color: #000000">price = $issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11102'))</span>

### Utils

- <span style="color: #000000">jsonEscapedString = $Utils.jsonEscape($issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_12500')))</span>

### Comment

<span style="color: #000000">Getting a comment that has passed through the transition:</span>

- <span style="color: #000000">comment = $comment </span>

### Field changes in transition

`$issue.get..`<span style="color: #000000">  methods might return the old or new values within a transition depending on the location of the post function.</span>

<span style="color: #000000">Assume that we have a transition that uses a transition screen in which </span><span style="color: #000000">*customfield_10123*</span><span style="color: #000000"> can be changed.</span>

- <span style="color: #000000">If the REST Service Caller post function is </span><span style="color: #000000">**BEFORE**</span><span style="color: #000000"> the </span><span style="color: #000000">**Update change history for an issue and store the issue in the database**</span><span style="color: #000000"> post function, </span><span style="color: #000000">**then **</span>`$issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123'))`<span style="color: #000000"> call would return the old value.</span>
- <span style="color: #000000">If the REST Service Caller post function is </span><span style="color: #000000">**AFTER**</span><span style="color: #000000"> the </span><span style="color: #000000">**Update change history for an issue and store the issue in the database**</span><span style="color: #000000"> post function, then </span>`$issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123'))`<span style="color: #000000"> call would return the new value.</span>

<span style="color: #000000">But, what if we need both values? </span>

<span style="color: #000000">You can use </span>`transientIssue`<span style="color: #000000"> for the updated fields within the transition instead of </span>`issue`

- <span style="color: #000000">productName = $transientIssue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_10123'))</span>

### Line breaks

<span style="color: #000000">You can remove line breaks with the </span><span style="color: #000000">*replaceAll() *</span><span style="color: #000000">method:</span>

- <span style="color: #000000">description = $issue.description.replaceAll("\n", "")</span>

### Render options

<span style="color: #000000">You can render parameters in HTML or Plain Text:</span>

- <span style="color: #000000">HTML render → $wikiUtils.wikiToHtml($comment)</span>
- <span style="color: #000000">Plain Text render → $wikiUtils.wikiToText($comment) </span>

### EscapeTool

<span style="color: #000000">You can escape parameters with the </span><span style="color: #000000">**EscapeTool,**</span><span style="color: #000000"> for example:</span>

- <span style="color: #000000"> issueSummary = $escape.html($issue.summary)</span>

<span style="color: #000000">The EscapeTool has lots of useful methods. You can find all of the methods</span> [here](https://velocity.apache.org/tools/1.4/generic/EscapeTool.html)<span style="color: #000000">.</span>

### MathTool

<span style="color: #000000">You can convert parameters with the </span><span style="color: #000000">**MathTool**</span><span style="color: #000000">. For example:</span>

- <span style="color: #000000">price = $mathUtils.toInteger($issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11100')))</span>

<span style="color: #000000">The MathTool has lots of useful methods. You can find all of the methods</span> [here](https://velocity.apache.org/tools/1.2/generic/MathTool.html)<span style="color: #000000">.</span>

> ❌ ### 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'))`.