Open Create Sub-Task Dialog after Main-Task transition

OK May 21, 2013

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

0 votes
pelizza
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.
December 17, 2015

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

0 votes
Shay Murphy September 2, 2014

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

0 votes
Roger Flory September 2, 2014

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

0 votes
Shay Murphy May 25, 2014

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

0 votes
OK May 24, 2014

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

0 votes
Shay Murphy May 21, 2014

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

0 votes
Nancy Blackwell
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.
May 21, 2013

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)

OK May 22, 2013

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?

Suggest an answer

Log in or Sign up to answer