Hide transition if issue has subtasks.

rajey March 16, 2020

I have certain workflows which are shared by issues and sub tasks.
I want to hide certain transitions in an issue if it has sub tasks.

For example:
I have a workflow with states (Required, In Progress, Complete and Not Required), both issues and sub tasks use the same workflow.
I only want the user (applies to all users) to see the transition to Not Required on the parent issue if it has any sub tasks. Otherwise sub tasks and issues (without sub tasks) transitions should be visible to the user.

Is it possible to do this?

I want to implement something like below which only applies to issues with sub tasks.

image.png

2 answers

1 accepted

0 votes
Answer accepted
rajey March 17, 2020

I figured it out.
There may be other ways of doing it.

I have this in my condition:

Boolean passesCondition = true;
if (!issue.isSubTask() && !issue.getSubTaskObjects().isEmpty()) {
passesCondition = false;
}

passesCondition

In my post function I add transition options (before validating the transition):

def User = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
TransitionOptions transOptions = new TransitionOptions.Builder().skipConditions().build();
def transitionValidate = ComponentAccessor.getIssueService().validateTransition(User, Issue.getId(), transitionId, new IssueInputParametersImpl(), transOptions );
if(transitionValidate.isValid())
{
def transition = ComponentAccessor.getIssueService().transition(User, transitionValidate);
}

 Basically you need to skip checking for condition in the post function when validating the transition.

0 votes
Cristian Ionescu
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.
March 16, 2020
rajey March 17, 2020

I tried the following (added it as a condition in a workflow transition): 

Boolean passesCondition = true;
if (!issue.isSubTask() && !issue.getSubTaskObjects().isEmpty()) {
passesCondition = false;
}

passesCondition

It "works" in that it blocks the transition for the user, however it also blocks my post function scripts from executing on parent tasks whenever:


passesCondition = false

 Is there a way to simply hide the transition option from the user, but allow scripts to execute normally.

Suggest an answer

Log in or Sign up to answer