Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

getting information from task to subtask tickets

Hi friends,


I am trying to create subtask automatically in a transaction from a task. I did it with post functions. My question is can we get the information we gave at task creation to subtask (for example custom fields at task creation  ) can anyone explain the process .\


Thanks in advance...




Antoine Berry Community Leader Apr 01, 2019


This is possible with an add-on such as scriptrunner.

Like Surender Reddy likes this

Can you explain to me how do it? actually, we are using the scriptrunner now. 

Antoine Berry Community Leader Apr 01, 2019

Go in the subtask workflow and add a Script Post-Function [ScriptRunner] postfunction in the create transition.

You need to specify your code. Here is a snippet that updates the current issue custom field with the parent custom field value (change the custom field id) : 

import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.component.ComponentAccessor

//Your custom field ID
int cfId = 10100
def cf = customFieldManager.getCustomFieldObject(cfId)
def cfValue = issue.getCustomFieldValue(cf)
def cfParentValue = issue.getParentObject().getCustomFieldValue(cf)

cf.updateValue(null, issue, new ModifiedValue(cfValue, cfParentValue), new DefaultIssueChangeHolder())

Of couse make sure that this workflow is only used by the sub-task you want to apply this update to. Else you need to add a condition to this script to check the Issue type.


Like Surender Reddy likes this

Thank You man this is working.

Antoine Berry Community Leader Apr 02, 2019

Glad to help ! You can mark the answer as accepted to lead other users with similar issues on this topic.

Hi friend, 

  In a project, I am working with the main task and that create subtask and then at the end to the main task. Is there any way we can move the main ticket to next stage after all subtasks are closed automatically. 


Thank YOU 

Antoine Berry Community Leader Apr 08, 2019


This is possible indeed. If you are satisfied with the initial answer, could you mark it as accepted ? I will come back some feedback on your question.

I don't see Accept option on this issue page. that's why I liked your answers  

I guess this is discussion thts the reason i dont see accept the answer 

Antoine Berry Community Leader Apr 08, 2019

Ah, too bad. Thanks for all the likes. :)

So here is quick example of how you can achieve it, but of course you need to adapt it to your specifics. 

This is assuming the "closed" status in your sub-task workflow is "Done". In your sub-task workflow, Add a post-function to your transition that leads to "Done" status at the last place. The script here checks if all the the subtasks of the parent are "Done", and proceeds to trigger a transition.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.util.JiraUtils

Integer subTaskDone = 0

Issue parentIssue = issue.getParentObject()
def parentSubTasks = parentIssue.getSubTaskObjects()
Integer subTaskCount = parentSubTasks.size()
String parentStatus = parentIssue.getStatus().getName()

for (currSubTask in parentSubTasks){
if (currSubTask.getStatus().getName() == "Done") {

if (subTaskCount == subTaskDone){
int transitionId
if (parentStatus == "In Progress"){
//The transition to trigger
transitionId = 51
else if (parentStatus == "To Do"){
transitionId = 41

if (transitionId){
//The user that triggers the transition. Make sure he has the permission to trigger it.
String currentUserKey = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getKey()

WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );

I hope that is what you are looking for.


Hello Antoine,

Can you help me where to add above code  in post-function?

--> i have to to add in "Script Post-Function [ScriptRunner]" ? or which post-function?



Antoine Berry Community Leader Apr 09, 2019

Yes exactly, you can add this very post function in the subtask transition that leads to the status "Done" in your subtask workflow.

Hello Antoine,

thanks for info. see the below screenshot when i click on the ""Script Post-Function" i need to follow the "Transition parent when all subtasks are resolved"  step??


Antoine Berry Community Leader Apr 09, 2019

Well I guess you can use this one, I did not notice it until now. My script would work with the "Custom script post-function", so it is up to you


Thanks Antoine,

i will work on "Custom script post-function" .


Log in or Sign up to comment

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you