Forums

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

can i change the transition of a subtask to resolved when other subtask is resolved

siva
Contributor
September 13, 2018

issue = finance

subtask= 1.bills due

                 2.bills cleared.

 

can i change the transition of the subtask (bills due ) to resolved automatically when the subtask ( bills cleared ) is resolved.

 

2 answers

0 votes
Orkun Gedik
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.
September 14, 2018

Hello @siva,

I wrote a script for you. This script works if there is a transition between subtasks' current status and resolved status. By the way, I thought there might be more than 2 subtasks. Therefore, I used for loop. Hope this helps.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger

Logger log = Logger.getLogger("Your script name")
log.debug ("Script started")

try {
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
Issue currentIssue = issue

if(currentIssue.getIssueTypeId() == "subtask id" && currentIssue.getStatusId() == "resolved status id"){
Issue parentIssue = currentIssue.getParentObject() // finance issue
List<Issue> subtasks = parentIssue.getSubTaskObjects()

for(Issue subtask : subtasks)
changeStatus(subtask,currentUser)
}
}catch(Exception e){
log.error(e)
}

private void progressTransition(Issue issue, ApplicationUser currentUser){
WorkflowTransitionUtil workflowTransitionUtil = JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class )
workflowTransitionUtil.setIssue(issue)
workflowTransitionUtil.setUserkey(currentUser.getKey())
workflowTransitionUtil.setAction("action id")
workflowTransitionUtil.validate()
workflowTransitionUtil.progress()
}

 

Regards

Orkun Gedik

siva
Contributor
September 14, 2018

Thanks a lot let me test it out .

Orkun Gedik
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.
September 14, 2018

Let me know if you need help. Good luck.

0 votes
Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2018

Hi,

 

You would need an automation, or even better a scripting add-on.

From there, sure you can and also much more.

 

Br

siva
Contributor
September 14, 2018

we are using BOB SWIFT CONFIGURATION and JSU,

 

but as i check the configuration , its confusing,

 

if i need to transition a second subtask to resolved if the 3rd sub task is resolved.

can you help me with the fields to choose

issue transition.PNGose ( please check the screenshot)

Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2018

I'm not so familiar with BobSwift, however the link relation between two subtasks does not exits.

In theory they are not linked at all with each other. Parent/Subtask relation exists only 1to1 (parent to/from subtask)

siva
Contributor
September 14, 2018

EXACTLY, so do i have to try any script , i think i can work it out with automation,

can you suggest any other options u are aware of ,

 

Thankyou.

Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2018

Do you have any possible scripting add-on?

I can gladly help with building the script.

 

If no, maybe someone else can relate to your current setup.

siva
Contributor
September 14, 2018

we use script runner,

and tried automation only works for servicedesk.

if you can help me with the script that would be great.

 

Thanks.

Gezim Shehu [Communardo]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2018

This might be similar.

We have 2 blocking sub-task issue types. If one resolves, checks for the other, if also that is resolved, it transitions the parent.

Let me know if you need any help adapting it.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.workflow.IssueWorkflowManager
import com.atlassian.jira.util.JiraUtils
import com.opensymphony.workflow.loader.ActionDescriptor
import com.atlassian.jira.ComponentManager

Issue issue = issue

MutableIssue parent = issue.getParentObject() as MutableIssue

if(parent.getIssueType().getName() == 'Demand' && parent.getStatus().getName()=='Mandatory Reviews')
{

    def otherIssueType = 'Information Security'
    if(issue.getIssueType().getName()=='Information Security')
    {
        otherIssueType = 'IT Architecture'
    }
    Collection subTasks = parent.getSubTaskObjects()
   
    for (Issue subtask : subTasks)
    {
        if(subtask.getIssueType().getName()==otherIssueType)
        {
            if(issue.getStatus().getName()=='Done' && subtask.getStatus().getName()=='Done')
            {
                def sdUser = ComponentAccessor.getUserManager().getUserByKey('robotuser')
                int actionId
                WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
                IssueWorkflowManager issueWflwMan = ComponentManager.getComponentInstanceOfType(IssueWorkflowManager.class)
                
                Collection<ActionDescriptor> coll = issueWflwMan.getAvailableActions(parent,sdUser)
                    for(ActionDescriptor ad : coll)
                    {
                        if(ad.getName().equals('Admin Skip Reviews'))
                        {
                        actionId = ad.getId()
                        }
                    }
                
                    workflowTransitionUtil.setIssue(parent)
                    workflowTransitionUtil.setUserkey('robotuser')
                    workflowTransitionUtil.setAction(actionId)
                    workflowTransitionUtil.validate()
                    workflowTransitionUtil.progress()
            }
        }
    }
}

siva
Contributor
September 14, 2018

Thanks a lot.

Suggest an answer

Log in or Sign up to answer