convert subtask to issue and change fields as well as ststus

We need to convert a sub task to a parent issue. I would like to have the ability to change the status and a set of fields.

I see the wizard has a place for workflow status and for changing fields. When the wizard runs the status portion of the wizard is not editable. 

Also, the field I need to change is not available.

How can I make the wizard render the status change and the fields I need edited.

2 answers

0 vote

The status change only happens if the workflow for the target issue type does not include the current status of the issue.  Similarly for the fields - it will only offer you the fields you actually need to change during the issue type change.

If you want to update other stuff, you have to do it as an edit, before or after the issue type move.

Another option would be to add a "Convert to Issue" workflow step (going back to the same state) and include a screen with the appropriate fields.  The workflow step will require a scriptrunner post function that does the actual conversion/unlink.  I recently wrote such a script:

import com.atlassian.jira.issue.issuetype.IssueType;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.util.IssueUpdateBean;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.link.IssueLinkManager;

IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager();
MutableIssue mutIssue = (MutableIssue)issue;
IssueType issueType = issue.getIssueTypeObject();
String newIssueTypeId = "3"; // Task

if (issueType.isSubTask()) {
    if(issueType.getName()=="Sub-Defect") {
        newIssueType=1; // Bug
    }
    Issue parentIssue = issue.getParentObject();
    IssueLink subTaskLink = issueLinkManager.getIssueLink(parentIssue.getId(),issue.getId(),10000);
	issueLinkManager.removeIssueLink(subTaskLink,ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser());    
	mutIssue.setParentObject(null);
    mutIssue.setIssueTypeId(newIssueTypeId);
}

This is certainly not the prettiest solution, as you potentially have to add this workflow step for every state.  You would also probably want to add a condition that prevents others from seeing the transition.  This won't work at all if you have a need to select the new issue type manually (as is done using the wizard) though you could probably hack that via a custom field that you set during the edit, and then reference/clear during the script.

I wrote this for the purpose of doing bulk "Convert to Issue" as that feature isn't available until JIRA7; however, the bulk convert didn't work, the wizard threw an error when the self-referencing state transition was selected.

At a guess, convert+edit is the more reasonable approach here.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

807 views 2 19
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