Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,501
Community Members
 
Community Events
165
Community Groups

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
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

301 views 0 9
Join discussion

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