Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Info message on issue create with ScriptRunner

Edited

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.
Jul 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

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

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