Versions Compared

Key

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

Script Runner Behaviours

For Message field v2.2.0+

Don't work for message type - "Show as is"

Info

It doesn't work if you select the message type in the field settings message type - "Show as is"

Settings

{baseUrl}/secure/jibrokMessageFieldsConfig!default.jspa

or gg + “message field settings"

...

Scripts in behavior can be very complex and run "not instantly", but for a second or more. In order for the plugin(message field) to wait for the result of script, in the plugin settings must set a timeout for waiting for a response from ScripRunner. If the "behavior" execution time exceeds the timeout, the plugin will not be able to display the received message. If the script is not large, it is usually enough to wait around 1 second. The 1000ms timeout is also almost invisible to users. If you need to set a longer waiting time, there is an option to display the default message from the field settings while waiting for the behavior script to execute. When "behavior" completes its execution, the message will be replaced with a new one.

Image Added

For example, you can set the message "Loading" in the field settings. It will be displayed until "behavior" is performed and the new message from script is set.

1. Hide field

Code Block
languagegroovy
def field = getFieldById("customfield_10000")
field.setHidden(true)

2.1 Update message (only body)

In the field settings must be set "Title" or "Body" - (default value)

Code Block
languagegroovy
def field = getFieldById("customfield_10000")
field.setFormValue("""
MESSAGE1 <b>test</b><br>
MESSAGE2 <b>test</b>
""")
Tip

2.2 Set message as JSON text

messageType values: successinfowarningerror, change (Type "Change" works only for "Show as flag - No" and Jira 8.4.0+), SIMPLE_VIEW

viewVersion: v1 (standard), v2 (big)

  • Code Block
    {
      "title": "Test title",
      "body": "test body",
      "messageType": "info",
      "asFlag": true,
      "viewVersion": "v1"
    }
Code Block
languagegroovy
def field = getFieldById("customfield_10000")
field.setFormValue("{\"title\":\"Test title\", \"body\":\"Test body\", \"messageType\":\"success\"}")

2.3 Set message as JSON

In the field settings must be set "Title" or "Body" - (default value)

...

Code Block
languagegroovy
import groovy.json.JsonOutput

def field = getFieldById("customfield_10000")
def message = [:]
message << [messageType: "warning"]
message << [title: "Test title2"]
message << [body: "<a>Test body2</a>"]

field.setFormValue(JsonOutput.toJson(message))

Service Desk

For Message field v2.4.0+

...