Info message on issue create with ScriptRunner

Daphnis Hessling July 2, 2019

Hi all,

I am trying to display an info message when a Jira issue is created using ScriptRunner. In the Documentation I found the following code:

package com.onresolve.jira.groovy.test.scriptfields.scripts

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import groovy.xml.MarkupBuilder
import com.atlassian.jira.config.properties.APKeys

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)

def List<Issue> blockingIssues = []

issueLinkManager.getInwardLinks(issue.id).each { issueLink ->
if (issueLink.issueLinkType.name == "Blocks") {
def linkedIssue = issueLink.sourceObject
if (!linkedIssue.assigneeId && !linkedIssue.resolutionObject) {
blockingIssues.add(linkedIssue)
}
}
}

if (blockingIssues) {
StringWriter writer = new StringWriter()
MarkupBuilder builder = new MarkupBuilder(writer)

builder.div(class: "aui-message error shadowed") {
p(class: "title") {
span(class: "aui-icon icon-error", "")
strong("This issue is blocked by the following unresolved, unassigned issue(s):")
}

ul {
blockingIssues.each { anIssue ->
li {
a(href: "$baseUrl/browse/${anIssue.key}", anIssue.key)
i(": ${anIssue.summary} (${anIssue.statusObject.name})")
}
}
}
}

return writer
} else {
return null
}

Unfortunately, this script only seems to work for the view screen, and not for the create screen.

Please have a look at the screenshot for a better understanding, what I am trying to achieve:

Info message on issue create.png

Many thanks in advance.

Regards,

Daphnis

2 answers

1 accepted

5 votes
Answer accepted
Roman Kersky
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2019

HI Daphnis


I created a new behavior mapping (in scriptrunner) and added 2 line =)

if(getFieldScreen().name == "BO: CR Create Issue Screen")
getFieldById("issuetype").setDescription("<div class=\"aui-message warning\"><p class=\"title\"><span class=\"aui-icon icon-warning\"></span></p><p>You are about to create a Checklist.</br>If you want create a Sub....</p></div>")



image.png

Timothy Ryner July 12, 2022

I yoinked this behavior for my purpose too.  Good stuff.

0 votes
Daphnis Hessling July 25, 2019

Hi Roman,

why didn't we think of solving this with Behaviours... :D
Anyway, thanks very much for the script. It works like a charm.

Regards,
Daphnis

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events