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:
Many thanks in advance.
Regards,
Daphnis
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>")
I yoinked this behavior for my purpose too. Good stuff.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.