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.

×
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

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

Edited
zaharovvv_suek_ru
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)


log.info('1. Test')
def isEpicIssueClosed = false;
def sourceIssue = issue.getParentObject()
log.info('Source issue is ' + sourceIssue)

log.info('2. isEpicIssueClosed BEFORE: ' + isEpicIssueClosed)
log.info('3. The creacted issue is: ' + issue + '. Its status is '
+ issue.getStatus().name)

if(issue.getStatus().name == 'Closed') {
isEpicIssueClosed = true;
}

log.info('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
at Script2802.run(Script2802.groovy:28)

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
TAGS
AUG Leaders

Atlassian Community Events