Hi there,
I need to set a specific value on a custom field within some linked issues but not all of them.
I'm using the 'Set field value of related issues (JMWE app)' Post Function and am using the 'Issues Returned by the following Groovy script' option to find the specific related issues that I require updated.
From the research I've carried out to date the following syntax returns a list of all of the related issues
issue.getLinkedIssues()
And these are the results:
ArrayList[Test-250, Test-249]
So this gives me all the related links which is great but I need to break that down further and only have the 'Result Value = Test-249' and not just list all of the related issues.
Is this doable? Does anyone have the correct syntax to use in this scenario?
Any help appreciated...
Thanks
Hello Kyle,
you could specify the following script into your transition:
import java.util.Collection;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.status.Status;
import com.atlassian.jira.workflow.JiraWorkflow;
import com.atlassian.jira.workflow.WorkflowManager;
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
Issue issue = issue;
Collection<Issue> subtasks = issue.getSubTaskObjects();
for(Issue sub : subtasks){
JiraWorkflow workflow = workflowManager.getWorkflow(sub);
Collection<Status> statuses = workflow.getLinkedStatusObjects();
Status destStatus = null;
for(Status status : statuses){
if(status.getName().equalsIgnoreCase("YOUR FINAL STATUS HERE")){
destStatus = status;
break;
}
}
workflowManager.migrateIssueToWorkflow((MutableIssue)sub, workflow, destStatus);
}
Please, specify your final status first.
Hope this helps,
Fabio
I did some changes on the provided script and it works well. thanks so much Fabio
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.