Linked Issue Validator condition

Bashar Haydar October 30, 2019

Dears,

i have 2 issue types Type 1 and Type 2

i need to block the user from creating type 2 using create button, as from the ticket created as Type 1 i have a transition to create a ticket with  issue type = Type 2 and link it to Type 1 ticket.

I succeeded with blocking the users from creating issues of type1 but the transition of type 1 is not anymore working, 

under the workflow of Type 1 i add create linked issue of type 2

Create Issue
Summary: Off Boarding %original_summary%
Description: This is an off boarding ticket created automatically via the worflow
Project: Original project
Issue type: Off Boarding (10602)
Priority: Parent's priority
Reporter: Current user
Assignee: Parent issue's assignee
Affected versions: None
Fixed versions: None
Components: Parent issue's components
Link: %original_key%, Link type: Relates, Link direction: From new issue to issue key
Copy original issue custom fields: Employee,Job Title

under the workflow of Type 2 i added this code under validator of create transition

if(issue.getLinkedIssues().size>0){
Issue issue = issue.getLinkedIssues()[0]
if(issue.status.name == 'EMPLOYEE LEFT')
return true
else return false
}
else return false

thank you.

2 answers

1 accepted

0 votes
Answer accepted
Andrew Laden
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.
October 30, 2019

I think you have a chicken and egg problem. You cant "get linked issues" of the type2 issue, because it doesn't exist yet when you are trying to create it. So your validator will always return false.

There are very few items that can be accessed in the create transition. If the requirement is "only allow this issue to be created if it is linked to another issue" i'm not sure you can do that.

What you may be able to do (and I havent tested this, so i cant prove it will work or not) is have a field that is not visible on the create screen, but can get set from the workflow, and check validation on that field. That way its like a "secret" flag that can only be set from automation, and the user can't set it in the create screen.

I'm not sure it will work though, the field may need to be on the screen for it to get set in the create.

You might want to look at making the "type2" issue a subtask. You might have more options with parent vs linked issues.

Bashar Haydar October 30, 2019

I converted the type2 to sub task, then I put the condition on level of sub task creation that should be inherent from a parent of type1 and it works.

Thank you. 

0 votes
Robert Nadon
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.
October 30, 2019

You can add a validator on the create transition that disallows one from creating an issue.   I would put in the error message.  "Do not create issue of Type 2, please use Type 1 for all new issues.  If you need to create a Type 2 issue, please use these steps..."

Bashar Haydar October 30, 2019

That's what I do and I succeeded with blocking the users from creating issues of type 2 but my problem here that am not able to create the ticket from the transition of type1

Robert Nadon
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.
October 30, 2019

There is a plugin called "Create on Transition" that makes that operation easy,  Is that what you are using or are you trying to just use groovy?

Bashar Haydar October 30, 2019

well am just using groovy under validators section of create transition of Type2

Suggest an answer

Log in or Sign up to answer