Automatic Creation of a Subtask when a bug issue is created?

when a bug issue is created,then automatically the subtask issue should be created.

How to approach and what are the steps?

4 answers

1 accepted

This widget could not be displayed.

Create your own post function and configure on create step

check the following link to how to write post function

http://www.j-tricks.com/1/post/2010/08/workflow-post-function.html

How to get the parent issue in my subtask issue function?

Issue currentIssue = (Issue) transientVars.get("issue");

Thanks Prasad,

I've written the following code

protected void

createSubTask(Map<String, Object> transientVariables, Map<String, String> args)

{

Issue originalIssue = (Issue)transientVariables.get(

"issue");

Issue parentIssue = originalIssue;

parentIssue =

this.issueManager.getIssueObject(originalIssue.getId());

MutableIssue issueObject =

this.issueFactory.getIssue();

issueObject.setIssueTypeObject(

this.constantsManager.getIssueTypeObject((String)args.get("field.subIssueTypeId")));

issueObject.setPriorityId(

this.constantsManager.getPriorityObject((String)args.get("field.subIssuePriorityId")).getId());

//issueObject.setSummary(replaceHelper.findReplace((String)args.get("field.subIssueSummary"), parentIssue, originalIssue, transientVariables));

Map params =

new HashMap();

params.put(

"issue", issueObject);

try

{

User user = ComponentManager.getInstance().getJiraAuthenticationContext().getLoggedInUser();

Issue subTask =

this.issueManager

.createIssueObject(user, params);

this.subTaskManager

.createSubTaskIssueLink(parentIssue, subTask, user);

ImportUtils.setIndexIssues(

true);

ComponentManager.getInstance().getIndexManager().reIndex(subTask);

}

catch

(Exception e)

{

log.error("Unexpected exception"

, e);

}

ImportUtils.setIndexIssues(

false

);

}

It is creating the issue but not creating the subtask issue returning //Create Issue:null//

error

This widget could not be displayed.

Try using the Create On Transition Plugin. You can use the post-function to create a subtask. Also go through this documentation

Hope this helps!

This widget could not be displayed.

Or use script runner, that will make life easier so that you need not write a plugin. The post function automatically defines an 'issue' object and you can use it.

I would go with Script Runner too. Groovy scripts are quite neat.

This widget could not be displayed.
Mizan Community Champion Jan 10, 2013

Create a separate workflow for bug issuetype and apply post function provided by Create on transition plugin as said by Naren on the crete transition of this workflow.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

85 views 1 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you