The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Scriptrunner Create Subtask for a task which is created by "Clones an issue, and links"

Nazimuddin Mohammed
September 9, 2018

Created a Task in a different project by using "Clones an issue, and links" with the following Additional issue actions.

import com.onresolve.scriptrunner.runner.util.UserMessageUtil;
import com.atlassian.jira.component.ComponentAccessor;

def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Name'}
issue.setCustomFieldValue(cf, 'Cloned Issue Epic Name' + sourceIssue.key + ': ' + sourceIssue.summary)

issue.summary = 'Cloned Issue ' + sourceIssue.key + ': ' + sourceIssue.summary

 The issue is created successfully and also linked with Issue link type "relates to".

Once this new issue is cloned and created, I would three subtasks to be created for the newly created issue by adding some actions to the existing script. 

How can this be achieved?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Tansu Akdeniz
Community Champion
September 10, 2018

Hi @Nazimuddin Mohammed,

Could you please take a look at this link, it may help.

You need to put this post-function to the Create transition in the workflow of newly created linked issue. 

Nazimuddin Mohammed
September 10, 2018

Unfortunately, that won't be possible in my scenario.

1. Project A ----clones and creates tickets to project B.

The tickets that are created in Project B by above step 1 should have subtask automatically created.

 

But, there are tickets that are created in Project B manually which does not need to have a subtask. Therefore, subtask should only be created automatically for ticket in project B when the ticket was created by Step 1 mentioned above. Can this be achived somehow?

Tansu Akdeniz
Community Champion
September 10, 2018

You can do it indeed.

For example, you may run "Clones an issue, and links" function via run as user (ex: AutoUser) than add condition to "Create subtask" function (if creator is AutoUser). So, sub-task will not be created for other users.

It is also possible run your own groovy script if you are familiar. There are so many examples on the web.