Hi,
I have an issuetype A that on create is linked to issuetype B (the link is created with element copy & sync app, and also the issue)
My goal is to prevent a creation based on fields that are in the issue I want to link to.
I know that in the create transition the link is not exist yet, but the data is out there (in the end the issue is linked in this transition, and the linked issue B is already exist).
How to reach the link/ the issue I want to link to? I tried to use issueLinkManager but it's incorrect. Also I tried to get the linked issue field but it return empty.
Hope that I'm clear enough, happy for any help!
In the end I found an answer.
Because its an issue that was not created yet, we need to "catch" the request and get the parameters from it. For this we need to use:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import com.opensymphony.workflow.InvalidInputException
import webwork.action.ActionContext
def fieldManager = ComponentAccessor.getFieldManager()
def linksSystemField = fieldManager.getField("issuelinks") as IssueLinksSystemField
def request = ActionContext.getRequest()
if (request) {
def params = request.getParameterMap()
def issueLinkingValue = linksSystemField.getRelevantParams(params) as IssueLinksSystemField.IssueLinkingValue
if (!(issueLinkingValue.linkDescription == "blocks" && issueLinkingValue.linkedIssues.size() > 0)) {
throw new InvalidInputException(IssueFieldConstants.ISSUE_LINKS,
"You must link a blocker issue at this transition")
}
}
I used the params array to get the sourceissueid (the issue I want to create from) and from there I continued with JQL to find the links that exist and my logic for this validator.
Notice: I didn't use issueLinkingValue, I uploaded the code I found, maybe it will help someone else.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.