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

Customizing the "Sub-task" types based on the Issue type.

Bharadwaj Jannu Dec 30, 2012

Requirement :

I have some Issue types under which sub-task issue types are defined.

Now I need to customize the sub-task issue types based on the Issue types.

Please any one provide the clue for this.

Also if any plug-in exist for this please specify.

Thanks

17 answers

1 accepted

1 vote
Answer accepted
Renjith Pillai Jan 02, 2013

I guess that was what we all mentioned as not possible apart from writing some javascripts for manipulating the create sub-task issue screen like the one below. Add an if condition for the issuetype selected. (in that sample 100008 is the sub-task issue type id).

<script type='text/javascript'>
    var intervalID;
    AJS.$(document).ready(function () {
        AJS.$("#issuetype100008").remove();

        AJS.$('#opsbar-operations_more').click(function () {


            AJS.$('#create-subtask').click(function () {

                intervalID = setInterval(clearSub, 1000);

            });

            function clearSub() {
                AJS.$("#issuetype100008").remove();
                clearInterval(intervalID);
            };

        });
    });
</script>​​​​​​​

C. Faysal Jan 02, 2013

i hear you renjith. just was wondering if it might be possible cause i also had an solution like this with "Clone" function from inside "More Actions"

https://answers.atlassian.com/questions/114724/how-to-modify-this-code-to-add-restrictions-to-a-projectrole

Like Marcel Nowakowski likes this
Bharadwaj Jannu Jan 02, 2013

I am not able to get Message Custom Field though i installed ToolKit Plugin

and added it to a field configuration and associated to a project.

Renjith Pillai Jan 03, 2013

Why do you need a 'Message custom field' for adding javascript, you can add it to the description of any field or in annoucement banner.

Bharadwaj Jannu Jan 03, 2013

Thanks Renjith, this approach make me to enter the script every time I create an issue.

Instead, I tried to analyze the blocking some subtasks in core code, I found a class file which is SubTaskBlockingCondition.class

it's java code look as follow

package com.atlassian.jira.workflow.condition;

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.config.SubTaskManager;
import com.atlassian.jira.issue.Issue;
import com.opensymphony.module.propertyset.PropertySet;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
import org.ofbiz.core.entity.GenericValue;

public class SubTaskBlockingCondition extends AbstractJiraCondition
{
public boolean passesCondition(Map transientVars, Map args, PropertySet ps)
{
Issue issue = getIssue(transientVars);
SubTaskManager subTaskManager = ComponentManager.getInstance().getSubTaskManager();

Collection subTasks = issue.getSubTasks();
boolean passCondition;
Iterator iterator;
if ((subTaskManager.isSubTasksEnabled()) && (!subTasks.isEmpty()))
{
passCondition = false;

for (iterator = subTasks.iterator(); iterator.hasNext(); )
{
GenericValue subTask = (GenericValue)iterator.next();

String statuses = (String)args.get("statuses");

StringTokenizer st = new StringTokenizer(statuses, ",");

while (st.hasMoreTokens())
{
String statusId = st.nextToken();

if (subTask.getString("status").equals(statusId))
{
passCondition = true;
break;
}

passCondition = false;
}

if (!passCondition)
return false;
}
}
return true;
}
}

Is my approach right and am I looking the exact requirement thing?

Renjith Pillai Jan 03, 2013

Oh no, that script was for the announcement banner.

Regarding class that you are referring to, it is a workflow condition class, not used while creating issues.

1 vote
Renjith Pillai Jan 01, 2013

Ah ok, that makes sense. But JIRA does not support it :( (Pending feature request here https://jira.atlassian.com/browse/JRA-7990 )

Probably you can do some javascript based solution to get rid of additional ones based on the issue typ.

1 vote
Tarun Sapra Community Leader Feb 03, 2015

Hi All,

One of the ways to implement this feature is to have a "loopback" workflow transition called "Create Subtask" , basically on the post-function of this transition you can create the sub-task using script runner plugin, though this way is more verbose but it kind of works well as the end-user sees the button "Create Subtask" clicks on this and the sub-tasks of a certain type can be generated.

0 votes
Naren Dec 30, 2012

I am not sure about your exact requirement. But you may like to have a look at this plugin -

https://studio.plugins.atlassian.com/wiki/display/GRV/Script+Runner

Hope this helps you!

0 votes
Renjith Pillai Dec 31, 2012

What do you want to customize? Screens? Transitions? Or the way sub-tasks are displayed in main task? Or auto closure of main-task?

0 votes
Bharadwaj Jannu Jan 01, 2013

I have defined a number of sub-tasks in a project under different issue types.

I need to retrieve

only those sub-tasks for bug type if I select 'sub-task for Bug',

only sub-tasks for New Feature if I select 'sub-task for New Feature' and soon.

How this is possible?

0 votes
Nic Brough [Adaptavist] Community Leader Jan 01, 2013

If I understand this correctly, you want to restrict the available sub-tasks based on the issue type of the parent? For example, under "bugs" you only want to allow the sub-tasks of "feature" and "test", although your sub-task list is feature, test and action?

This is not currently possible directly, and I've not seen any plugins that will fix it. There are some ways to block people from creating the wrong types, but none that actually limit the list available. I think your options are to do something with javascript, or to start hacking core code. I'd also start with a look at the behaviours plugin, I don't know if it can meet this particular need, because I've not looked.

0 votes
Bharadwaj Jannu Jan 01, 2013

I'm trying to make a filter as follow

project = MyProject AND parent = MYP-1

--This implies in a project called MyProject, the subtasks are retrieved based on the parent key MYP-1(which is a bug type)--

Now I want to know Is there any method which returns a issue key when a issue type(bug) is given?

0 votes
Bharadwaj Jannu Jan 01, 2013

Which meant the issue key for a paritcular issue should be returned,

when I give the Bug issue type;

e.g:I defined number of issues of type Bug and each one have a separate Issue Key

I need to get those Keys.

0 votes
Renjith Pillai Jan 01, 2013

I am lost :(

I didn't get what you meant by 'returns a issue key when a issue type is given'

Hope Nic understands what you meant.

0 votes
Nic Brough [Adaptavist] Community Leader Jan 01, 2013

I'm still not quite understanding this.

I'm really not sure what filters have to do with the original question, but the answer to that is to use the "parent" function in JQL - see https://confluence.atlassian.com/display/JIRA/Advanced+Searching#AdvancedSearching-Parent . A filter for "parent = myp-1" will work. If you only want "bug" sub tasks, then add the clause "and issuetype = bug"

0 votes
Bharadwaj Jannu Jan 01, 2013

MYP-1 is the issue key of an issue(Bug type)

Similarly another issue(Bug type) may have a key MYP-5

Suppose both of them has sub-tasks

If I am able to get those keys, then i can use

parent='MYP-1' or parent='MYP-5'

0 votes
Nic Brough [Adaptavist] Community Leader Jan 01, 2013

Yes, correct.

Now I do not see where the question is. You can get teh subtasks for both of your issues with what you've just said.

0 votes
Bharadwaj Jannu Jan 01, 2013

Now I want to know Is there any method which returns a issue key when a issue type(bug) is given?

0 votes
Nic Brough [Adaptavist] Community Leader Jan 01, 2013

I'm really struggling to understand what the question here is.

I've already pointed out that "issuetype = bug" is the clause you need to identify bugs.

0 votes
Bharadwaj Jannu Jan 02, 2013

The requirement just changed as:

I defined a number of sub-tasks issue types in a project like subtask1,subtask2,...,subtask10;

When I try to create a subtask,

I need to display subtask1,subtask5 for Bug

I need to display subtask4,subtask5 for New Feature

and soon.

i.e., let's consider bug type issue

then in More actions, I click create a sub-task for this?

then a window is displayed

and in it, I want to display only some sub-task issue types for bug type issue

How can this be achieved?

0 votes
C. Faysal Jan 02, 2013

i think i've seen some question like this here before.

i believe the goal is to seperate the possibile sub-task issue-types depending on what the parent issue-type is.

am i right?

so lets check this scenario...maybe other will understand that one better

Issue-Types (Parent)

"Story"

"Bug"

Issue-Types (Subtask)

"story task"

"bug task"

if your parent issue is a "Story" you only want to see "story task" as possible selection when you're creating a subtask

if your parent issue is a "Bug" you only want to see "bug task" as possible selection when you're creating a subtask

am i right so far?

Bharadwaj Jannu Jan 02, 2013

100% correct and how can we achieve this?

C. Faysal Jan 02, 2013

i see this was requested long time ago

https://jira.atlassian.com/browse/JRA-7990

C. Faysal Jan 02, 2013

well unfortunately that's not that easy..as you can read in the feature request i've posted above.

this is not a feature of jira and nobody knows if or when it will be integrated.

i am not sure but i think you could put some javascript inside a velocity processed message field to hide some sub-task issuetypes if the parent issue-type matches a certain selection.

if customfield "Message Custom Field (for edit)" will be shown during issue-creation you can add javascript to it where you set several conditions to hide/show. i believe you must use strings there

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

9,982 views 46 44
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