Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


Prevent creation "issue B" of "Project B" by clicking button "Create linked issue" from "issue A"

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.
Aug 03, 2018

I would like to prevent creation "issue B" of "Project B" by clicking button "Create linked issue" from "issue A", if "issue A" has status "Closed".

And to do this, I used two approaches:
1. The first way. I created "Validator" of "Create" transition in "Workflow B" of "issue B" and wrote the following code:

def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)'1. Test')
def isEpicIssueClosed = false;
def sourceIssue = issue.getParentObject()'Source issue is ' + sourceIssue)'2. isEpicIssueClosed BEFORE: ' + isEpicIssueClosed)'3. The creacted issue is: ' + issue + '. Its status is '
+ issue.getStatus().name)

if(issue.getStatus().name == 'Closed') {
isEpicIssueClosed = true;
}'4. isEpicIssueClosed AFTER: ' + isEpicIssueClosed)
isEpicIssueClosed == false


But I see the following error:

2018-08-02 18:11:06,513 INFO [acme.CreateSubtask]: 1. Test

2018-08-02 18:11:06,513 INFO [acme.CreateSubtask]: Source issue is null
2018-08-02 18:11:06,515 INFO [acme.CreateSubtask]: 2. isEpicIssueClosed BEFORE: false
2018-08-02 18:11:06,515 INFO [acme.CreateSubtask]: 3. The creacted issue is: issue B
2018-08-02 18:11:06,517 ERROR [utils.ConditionUtils]: *************************************************************************************
2018-08-02 18:11:06,517 ERROR [utils.ConditionUtils]: Condition failed on issue: null, built-in script:com.onresolve.scriptrunner.canned.jira.workflow.validators.SimpleScriptedValidator
java.lang.NullPointerException: Cannot invoke method getName() on null object

Consequently, it does not work like I wanted.

2. The second way. I used ScriptRunner approach "Hide system or plugin UI element" and wrote the following code:

!(jiraHelper.project?.key == "LO"
&& issue?.issueType?.name == 'Epic'
&& issue?.getStatus()?.getName() == 'Closed')

But this approach hides button "Create linked issue" and I cannot create any issue of other projects such as "Project C", "Project D", "Project E".

So guys, how is it possible to prevent creation "issue B" of "Project B" by clicking button "Create linked issue" from "issue A", if "issue A" has status "Closed"?

0 answers

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events