convert subtask to issue and change fields as well as ststus

Scott Ocamb November 29, 2015

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 votes
Jeremy Gaudet
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.
November 29, 2015

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.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 29, 2015

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.

Suggest an answer

Log in or Sign up to answer