Hi.
I used CustomField in ScriptRunner to create a field to view the Assignee of the LinkedIssue.
I want to exclude the Assignee of EpicLink, Sub-task from this, but I'm not sure how.
If you can tell me how to do this, I would be very grateful.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.user.ApplicationUser
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issueManager = ComponentAccessor.getIssueManager()
def linkedAssignees = []
def allLinks = issueLinkManager.getOutwardLinks(issue.id) + issueLinkManager.getInwardLinks(issue.id)
allLinks.each { IssueLink issueLink ->
def linkedIssue = issueManager.getIssueObject(issueLink.sourceId ?: issueLink.destinationId)
if (linkedIssue.assignee) {
linkedAssignees.add(linkedIssue.assignee)
}
}
linkedAssignees = linkedAssignees.unique()
return linkedAssignees
Hi @박성우
In your description, you mentioned:-
I used CustomField in ScriptRunner to create a field to view the Assignee of the LinkedIssue.
I want to exclude the Assignee of EpicLink, Sub-task from this, but I'm not sure how.
If you can tell me how to do this, I would be very grateful.
Please clarify what do you mean by excluding Assignee of Epic Link, Sub-task.
Do you mean you want to exclude Assignees of an Epic and Assignees of Sub-Tasks?
Thank you and Kind regards,
Ram
Thanks.
After applying the above script, not only the assignee of the LinkedIssue is displayed, but also the assignee of the EpicLink and the assignee of the Sub-task.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @박성우
import com.adaptavist.hapi.jira.issues.Issues
def issue = Issues.getByKey('MOCK-1')
def assignees = [] as ArrayList<String>
issue.getOutwardLinks { excludeSystemLinks = false }.each { issueLink ->
def targetIssue = issueLink.destinationObject
if ( !(targetIssue.issueType.name in ['Epic', 'Sub-task']) ) {
assignees << targetIssue.assignee.name
}
}
assignees.unique()
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
I have run this example on the ScriptRunner Console, hence you will need to modify it according to the ScriptRunner feature you are using.
Also, I have used ScriptRunner's HAPI feature to simplify the code.
Below is a screenshot of the ScriptRunner Console for your reference:-
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
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.