---
title: "Groovy in JMWE"
canonical: "https://support.appfire.com/space/JMWE/461931220/Groovy%20in%20JMWE"
format: markdown
---
> Macro (aura-html)

JMWE provides a wide array of easy to use workflow extensions to create advanced workflows. However, some advanced customization will require using scripting to further configure these extensions, such as<span style="color: #404040">:</span>

- <span style="color: #404040">Auto-assign the issue to a user based on the request type</span>
- Unlink issues of the current issue only when the issue has been rejected
- Notify the user with a probable date of resolution for the issue through a comment

### Writing a Groovy script in JMWE

A [Groovy editor](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461897846) <span style="color: #000000">is provided in all the applicable workflow extension configuration screens and the JMWE administration page to write your Groovy scripts. You can either write them directly in the built-in editor, or use any IDE and then copy them to the editor.</span> The built-in editor automatically indents your code, checks for syntax errors, colorizes keywords, comments, variables, and so on. JMWE includes a [Groovy script tester](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461766715) tool that lets you test your script against any issue. This allows you <span style="color: #000000">to debug your script and make changes without having to actually trigger the transition and/or look at the Jira logs to see the outcome.</span>

**<span style="color: #000000">Writing a Groovy script:</span>**<span style="color: #000000"> </span><span style="color: #000000">In the workflow extension configuration, select </span>`Groovy expression`<span style="color: #000000"> or</span>` Groovy template`<span style="color: #000000"> as the </span>`Value type`<span style="color: #000000"> (when available). For example to write a script to access the key of an issue</span>**<span style="color: #000000">:</span>**

```groovy
issue.key
```

<span style="color: #000000">**Testing the Groovy script: **</span><span style="color: #000000">After writing the Groovy script, c</span><span style="color: #000000">lick on </span>`Test Groovy Script`<span style="color: #000000">. </span><span style="color: #000000">A modal dialog window opens, asking you to pick an issue to run the Groovy script against, as well as a linked issue, when applicable. </span><span style="color: #000000">Select an issue key. </span><span style="color: #000000">Click on </span>`Test`<span style="color: #000000">. </span><span style="color: #000000">The result of the script is displayed.</span>

![image](media://e0f0f8c0-6afc-45ed-9a80-a7c151d35069)

### Accessing Jira objects from your Groovy script

<span style="color: #000000">An interface </span><span style="color: #000000">is a blueprint of a class. It has static constants and abstract methods. </span><span style="color: #000000">In JMWE you will be using the Groovy language and </span>[<span style="color: #000000">Jira APIs augmented by JMWE</span>](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/462127173)<span style="color: #000000">. The most common interface that you will be using in your scripts is the </span>[<span style="color: #000000">Issue interface</span>](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461537734)<span style="color: #000000">. This API provides the methods you can use on any </span>`Issue`<span style="color: #000000"> object. JMWE also exposes global variables and functions to access contextual information in your script. For example, to access the issue being transitioned, you can use the global </span>[<span style="color: #000000">issue</span>](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78055921)<span style="color: #000000"> variable.</span>

```
issue.get("summary")
```

<span style="color: #000000">To access the current user, you can use the </span>[<span style="color: #000000">currentUser</span>](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78055921)` `<span style="color: #000000">global variabl</span>e.

```
currentUser
```

To access the linked issue being processed (e.g. in a Comment Linked Issues post-function), you can use the [linkedIssue](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78055921) variable. Note that it is only applicable to workflow extensions that operate on linked issues.

```
linkedIssue.assignee
```

To log information in your script for debugging purposes, you can use the [log](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/78055921) global variable. You can use the WARN level to output information in the log as well as the tester result.

```
log.warn("Reporter set by the script is: " + newUser.name) //where newUser is a variable holding an ApplicationUser object
```

JMWE has [some more variables and global functions](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461799437) that are exposed to your Groovy scripts.