I've added a Post Function - Script Runner function to one of the workflow transition steps to clone the issue and would like to only perform the clone if none of the issue links have an issue type of 'Change Control' for example.
I've found a lot of example on the internet but none seem to cover finding all the issue links then checking each issue type.
thank you
This is a script I use to transition linked issues.
I assume you can just adjust to use it as a condition
import com.atlassian.jira.user.*
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.*
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
//Get the current Issue
Issue issue = issue;
//Get User
def userManager = ComponentAccessor.getUserManager()
def sdUser = userManager.getUserByKey('sdagent')
List<IssueLink> allOutIssueLink = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId());
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
IssueWorkflowManager issueWflwMan = ComponentManager.getComponentInstanceOfType(IssueWorkflowManager.class);
//Define action name for parent issue
String actionName = "Resolve";
List<Issue> allParentIssues = new ArrayList<Issue>();
List<Issue> allChildIssues = new ArrayList<Issue>();
Boolean allClosed = true;
int actionID;//you might want to change allOut with allIn depending on the link type
//Get all Parent Issues
for (Iterator<IssueLink> outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
IssueLink outIssueLink = (IssueLink) outIterator.next();
allParentIssues.add(outIssueLink.getDestinationObject());
}
//here is the iteration for each linked issue, check again inward or outwards links
for(Issue parentIssue : allParentIssues){
List<IssueLink> allInwardIssueLink = ComponentAccessor.getIssueLinkManager().getInwardLinks(parentIssue.getId());
//Get all linked Issues
for (Iterator<IssueLink> inIterator = allInwardIssueLink.iterator(); inIterator.hasNext();) {
IssueLink inIssueLink = (IssueLink) inIterator.next();
allChildIssues.add(inIssueLink.getSourceObject());
}
//If all closed, update the parent issue
if(allClosed) {
MutableIssue mutableParentIssue = (MutableIssue) parentIssue;
if(parentIssue.projectObject.name=='Service Center'){
def disallowedStatuses = ['Resolved','Closed','Done','Cancelled']
if(!disallowedStatuses.contains(parentIssue.getStatus().getName())){
Collection<ActionDescriptor> coll = issueWflwMan.getAvailableActions(parentIssue, sdUser);
for(ActionDescriptor ad : coll) {
if(ad.getName().equals(actionName)) {
actionID = ad.getId();
}
}
workflowTransitionUtil.setIssue(mutableParentIssue);
workflowTransitionUtil.setUserkey('userkey');
workflowTransitionUtil.setAction(actionID);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
}
}
}
//x
Thank you and I'll give it try
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.