Open Create Sub-Task Dialog after Main-Task transition

We have two issue types: Main-task and Sub-Task

After pressing the Workflow-Button "need additional information" of a main-task, the status should switch to "pending" and the create sub-task dialog should open immediately. In the new dialog we want to create a sub-task like "ask john doe for more info"

Question: Is it possible to open the create Sub-Task-Dialog after a Main-Task transition?

Any ideas to solve this behavior?

7 answers

This widget could not be displayed.

In the transition in the workflow, you assign the Sub-task dialog:

Transition: Create Compliance Request

You are viewing an active workflow. Create a draft workflow.

Transition View: Create Compliance Action Request

Then, in the post-function of the transition you call a script:

All Conditions (1) Validators (0) Post Functions (6)

Set issue status to the linked status of the destination workflow step.
— THEN
Add a comment to an issue if one is entered during a transition.
— THEN
Update change history for an issue and store the issue in the database.
— THEN
Re-index an issue to keep indexes in sync with the database.
— THEN
Fire a Generic Event event that can be processed by the listeners.
— THEN
Script /data/atlassian/jira/scriptrunner/RPDCreateComplianceActionRequest.groovy will be run.
The script will create the subtask:
issueObject = issueFactory.getIssue()
issueObject.setProjectObject(issue.getProjectObject())
issueObject.setIssueTypeObject(subtaskIssueType ) 
issueObject.setDescription(issue.getSummary())
issueObject.setReporter(currUser)
issueObject.setSummary(issue.getSummary())
issueObject.setDueDate(issue.getDueDate())
issueObject.setPriority(issue.getPriority())
issueObject.setParentObject(issue)

//bunch of code here putting the customfields onto the object

subtaskIssue = issueManager.createIssueObject(currUser, issueObject)

Hi Nancy,

thx for your fast answer, but your solution doesn't work for me.

Reasons:

- The Screen is not the original Create-SubTask Screen. The Subtask-Task-Type picker is missing

- The Screen-Title and Submit-Button Label is not correct

- The entered Attributes in the Subtask-Screen are also persist in the main-task (e.g. summary)

Any other idea?

This widget could not be displayed.

Hi Olaf,

Were you able to come up with a solution for this? I am trying to do something similar, where I would like a workflow transition to launch the "ceate Sub-Task" Dialog,

thanks,

Shay

This widget could not be displayed.

Hi Shay,

our requirement are changed a little bit:

- Execute sub-transition (in background)

- Change the status of the sub-issue

- Show a prefilled create sub-issue dialog

- User can create the sub-issue or cancel the creation process. status is still changed.

- Create a issue link between the first sub-issue (initiator) to the second issue

To solve the above requierments I do a lot of JavaScript-Stuff and deploy this as a plugin.

Some highlights:

- remove/add transtion class from transition-button

$(button).removeClass("issueaction-workflow-transition");
$(button).addClass("issueaction-create-subtask");

- replace current parentId with correct parentId

- replace default click-handler with own click-handler

$(button).unbind("click");
$(button).click(handleOwnClickHandler);

- make rest-call for transtion while create sub-issue dialog is visible

var szURL = AJS.contextPath() + '/rest/ontrack-rest/2.0/workflowservice/performworkflowaction';
var postData = {
"issueId": issueId,
"action": action
};

Maybe this information helps a little bit.

Olaf

This widget could not be displayed.

Hi Olaf,

Thank you for the reply. That is helpful.

I did something similar in the end to resolve the problem, I used some simple JS to find the workflow transition i.e. "Create New Version" and replace the class and the href with those of the actual create-task button.

<script type="text/javascript">

AJS.$(document).ready(function($) {

if (AJS.$("a:contains(Create New Version)")){

var href = AJS.$(".issueaction-create-subtask").attr('href')

AJS.$("a:contains(Create New Version)").addClass("issueaction-create-subtask").attr("href", href);

}

})

</script>

thanks again,

Shay

This widget could not be displayed.

Shay, I am looking to do something similar. I am rather new to Jira, where exactly would you place the JS above?

This widget could not be displayed.

Hi Roger, I am quite new to JIRA myself and have found the only way to execute JS on the page is to embed it in a CustomField description.

So find a customfield that appears on the view screen of the issue in the CustomField section of Issue admin. Edit the CustomField and in the description add your javascript as above. You will want to replace the label "Create New Version" with the label of your transition.

Now when you click on the transition it should open the create-subtask popup.

regards,

Shay

This widget could not be displayed.

Hey guys, It seems to work, but whatever parentIssueId I use, the actual parent issue displayed on the dialog is the one being displayed on the view issue screen. If I open the dialog from another screens, no parent issue is displayed on the dialog. How can I set the parentIssueId? Any clues? Thanks

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 yesterday in Statuspage

What are your best incident management tips and stories? #HugOps

 👋Community members! Downtime happens. And great incident response takes a village. Teams like Support, Dev, SRE, Ops, IT, and Marketing have to come together to resolve the problem while keep...

35 views 2 3
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