Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Groovy editor in JMWE

Starting with version 5.0.0, the JMWE add-on is provided with a Groovy script editor and tester in the post-function configuration screens. This document details the Groovy editor in JMWE, its features, its availability and keyboard shortcuts. 

On this page:

Groovy editor features

Groovy editor in JMWE is where you should be writing your Groovy scripts. This editor has the

  • Basic features like automatically indenting the code, checking for syntax errors in the code, colorizing keywords, comments, variables and so on and
  • Advanced features, such as Find and Replace, that are available through keyboard shortcuts. 

Groovy Help in the Groovy editor

The editor also has a Groovy help section that assists you in writing your Groovy scripts with ease. It has the following tabs:

Expected Value: This tab lists the possible expected values for the selected Field and Value Type. This is applicable in contexts where you set a field value or comment an issue or write a conditional Groovy script. Select the Field and Value Type. Click on Expected Value. The help editor displays the expected values for the selected field based on the value type. Expected values of all the fields are listed here.

Templates: This tab lists a few important Groovy markups that you might want to use to create your Groovy templates. This is applicable in contexts where you set a field value, comment an issue, write content (in the Email issue post-function) or a JQL search expression using Groovy templates. Hover over any button to get the information, click on it to insert it into the editor. For more information, click here.

Globals: This tab lists the Global variables and functions that are available for your Groovy expressions and templates. Hover over any button to get the information, click on it to insert it into the editor. For more information, click here.

Issue Fields: This tab lists the fields of the current issue, original issue, linked issue or the parent issue depending on the context. Select a field and an issue variable. The help editor displays a few Groovy expressions accessing the field values, sub-fields etc by the field name. You can refer to the issue either by the field name or the field ID.  Groovy expressions to access all the fields of an issue are listed here.

Issue Methods: This tab lists the methods applicable to the current issue, original issue, linked issue or the parent issue depending on the selected issue variable. Hover over any button to get the information, click on it to insert it into the editor. For more information, click here.

Interfaces: This tab can describe any Jira, Groovy or Java interface or class. Select an interface and the editor displays the properties and methods of the selected interface. Hover over any button to get the information, click on it to insert it into the editor. For more information, click here.

More help: This menu gives you access to additional help pages.

Ensure the Groovy script or template inserted into the editor matches the Groovy input type selected in the post-function (wherever applicable). If not, a warning message is displayed notifying you to modify the input type.

Groovy Help in the Groovy editor

Suppose you want the issue to get assigned to the Project Lead if left unassigned.

  • Add the Set field value post-function to the transition of the issue workflow.
  • Select the Assignee field.
  • Select Groovy expression in the Value type.
  • Click on Issue Fields tab of the help editor.
  • Select Project under Select a field.
  • Under the Accessing sub-fields section locate the Groovy expression to access the Project Lead.
  • Click on it to insert it into the editor.
  • Go to the Conditional Execution section of the post-function and activate it.
  • Click on Issue Fields of the help editor.
  • Select Assignee under Select a field.
  • Under the Testing the field's value section locate the Groovy expression to test whether the Assignee field is empty.
  • Click on it to insert it into the editor.

Groovy editor availability

  • The Groovy script editor in JMWE is available on the:

    • Post-function configuration screen when you select:
      • Groovy expression/Groovy Template as Value type in the post-functions that set a field value
      • Groovy expression/Groovy Template as Comment type in the post-functions that comment an issue
      • the Conditional execution option in any post-function
    • Post-function configuration screen of the Create/Clone issue(s) post-function when you select:
      • Calculated as Project
      • Calculated as Parent issue
      • Set field value from Groovy or Set field value from Groovy template while setting a field in Set fields of new issue
      • Groovy expression/Groovy Template as Comment type while adding a comment to the current issue
    • Post-function configuration screen of the Email issue post-function while writing the Email content and recipients
    • Post-function configuration screen of the Link issues to the current issue post-function while writing the JQL search expression
    • Post-function configuration screen of the Unlink issues from the current issue post-function
    • Configuration screens of the Scripted (Groovy) condition, Scripted (Groovy) validator and Scripted (Groovy) operation on issue post-function
    • Groovy console admin screen that allows you to test/run Groovy scripts

Groovy editor toolbar

The Groovy editor has a toolbar with the following features. Clicking on:

  • Find: Opens the search box. Use /re/ syntax for regexp search
  • Find Next: Finds the next occurrence of a search
  • Replace: Opens the Replace window. Replace a certain text with a specified text
  • Test Groovy Script: Opens the Test Groovy script window to input the Issue key. Use it to test your script.
  • Test again: Retests your script

The shortcuts for Find, Find Next and Replace are shown in the table below.

Groovy editor keyboard shortcuts

You can use the following shortcut keys as an alternative to the mouse when working in this editor, while the cursor is active in a code editor: 

CommandDescriptionPCMac

find

Opens the search box. Use /re/ syntax for regexp search

Ctrl-FCmd-F

findNext

Post a search, finds the next occurrence of the searchCtrl-GCmd-G
findPrevPost a search, finds the previous occurrence of the searchShift-Ctrl-GShift-Cmd-G

replace

Opens the Replace window.

Shift-Ctrl-FCmd-Alt-F
replaceAllOpens the Replace all windowShift-Ctrl-RShift-Cmd-Alt-F
selectAllSelect the whole content of the editorCtrl-ACmd-A
singleSelectionWhen multiple selections are present, this deselects all but the primary selectionEscEsc
killLineDeletes the part of the line after the cursor. If that consists only of whitespace, the newline at the end of the line is also deleted.
Ctrl-K
deleteLineDeletes the whole line under the cursor, including newline at the end.Ctrl-DCmd-D
delWrappedLineLeftDelete the part of the line from the left side of the visual line the cursor is on to the cursor.
Cmd-Backspace
delWrappedLineRightDelete the part of the line from the cursor to the right side of the visual line the cursor is on.
Cmd-Delete
undoUndo the last changeCtrl-ZCmd-Z
redoRedo the last undone changeCtrl-YShift-Cmd-Z or Cmd-Y
undoSelectionUndo the last change to the selection, or if there are no selection only changes at the top of the history, undo the last change.Ctrl-UCmd-U
redoSelectionRedo the last change to the selection, or the last text change if no selection changes remain.Alt-UShift-Cmd-U
goDocStartMove the cursor to the start of the document.Ctrl-HomeCmd-Up or Cmd-Home
goDocEndMove the cursor to the end of the document.Ctrl-EndCmd-End or Cmd-Down
goLineStartMove the cursor to the start of the line.Alt-LeftCtrl-A
goLineStartSmartMove to the start of the text on the line, or if we are already there, to the actual start of the line (including whitespace).HomeHome
goLineEndMove the cursor to the end of the line.Alt-RightCtrl-E
goLineRightMove the cursor to the right side of the visual line it is on.
Cmd-Right
goLineLeftMove the cursor to the left side of the visual line it is on. If this line is wrapped, that may not be the start of the line.
Cmd-Left
goLineUpMove the cursor up one line.UpCtrl-P
goLineDownMove down one line.DownCtrl-N
goPageUpMove the cursor up one screen and scroll up by the same distance.PageUpShift-Ctrl-V
goPageDownMove the cursor down one screen and scroll down by the same distance.PageDownCtrl-V
goCharLeftMove the cursor one character left, going to the previous line when hitting the start of the line.LeftCtrl-B
goCharRightMove the cursor one character right, going to the next line when hitting the end of the line.RightCtrl-F
goWordLeftMove the cursor to the start of the previous word.
Alt-B
goWordRightMove the cursor to the end of the next word.
Alt-F
goGroupLeftMove to the left of the group before the cursor. Ctrl-LeftAlt-Left
goGroupRightMove to the right of the group after the cursor.Ctrl-RightAlt-Right
delCharBeforeDelete the character before the cursor.Shift-BackspaceCtrl-H
delCharAfterDelete the character after the cursor.DeleteCtrl-D
delWordBeforeDelete up to the start of the word before the cursor.
Alt-Backspace
delWordAfterDelete up to the end of the word after the cursor.
Alt-D
delGroupBeforeDelete to the left of the group before the cursor.Ctrl-BackspaceAlt-Backspace
delGroupAfterDelete to the start of the group after the cursor.Ctrl-DeleteCtrl-Alt-Backspace or Alt-Delete
indentAutoAuto-indent the current line or selection.Shift-TabShift-Tab
indentMoreIndent the current line or selection by one indent unit.Ctrl-]Cmd-]
indentLessDedent the current line or selection by one indent unit.Ctrl-[Cmd-[
defaultTabIf something is selected, indent it by one indent unit. If nothing is selected, insert a tab character.TabTab
transposeCharsSwap the characters before and after the cursor.
Ctrl-T 
newlineAndIndentInsert a newline and auto-indent the new line.EnterEnter
toggleOverwriteFlip the overwrite flag.InsertInsert
Group

A group is a stretch of word characters, a stretch of punctuation characters, a newline, or a stretch of more than one whitespace character.