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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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
Community showcase
Published in Marketplace Apps & Integrations

Do Not Lose your Customer’s Trust

Missing deadlines is one of the biggest problems every team lead wants to avoid when dealing with managed services. When the customer contracts your company to help with IT services it is expected th...

24 views 0 0
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you