Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,558,628
Community Members
 
Community Events
184
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...

 

 

4 comments

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 01, 2019

Hi,

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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.

Antoine

Like Surender Reddy likes this

Thank You man this is working.

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 08, 2019

Hi,

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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") {
subTaskDone++
}
}

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 );
workflowTransitionUtil.setIssue(parentIssue);
workflowTransitionUtil.setUserkey(currentUserKey)
workflowTransitionUtil.setAction(transitionId);
workflowTransitionUtil.progress();
}
}

I hope that is what you are looking for.

Antoine

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?

 

Thanks.

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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??

1.PNG

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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

Like CHILLAMCHARLA VARUN likes this

Thanks Antoine,

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

Comment

Log in or Sign up to comment