Hello Team,
im trying to check if a type of link is added during transition,However it is not working.
Please help me on this.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.fields.IssueLinksSystemField
import com.opensymphony.workflow.InvalidInputException
import webwork.action.ActionContext
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
def transit = false
if(issueLinkManager.getOutwardLinks(issue.id)*.issueLinkType.name.contains('Duplicate'))
{
transit = true
}
else
{
transit = false
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 == "Duplicate") && issueLinkingValue.linkedIssues.size() > 0))
{
transit = false
}
else {
transit = true
}
}
}
return transit
Hi,
Could You please clarify how You added script in transition? Are You using validator?
In my jira next fragment work well.
issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate')
Try add log.error(message) to debug script.
B.R.
Hello @Andrew ,
we are checking if a link is already added or if the required type of link is added during the transition.
As you can see we are using the above code to achieve that.
in the above code the first part is working perfectly however i'm not able to figure how to check if a link is added during transition.
Please provide a solution, i can figure out what is wrong in my code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I checked on my local instance. If link 'duplicaties' added in transition validator throw exception.
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 == "duplicates" && issueLinkingValue.linkedIssues.size() > 0)) {
throw new InvalidInputException(IssueFieldConstants.ISSUE_LINKS,
"You must not link a duplicates issue at this transition")
}
}
I based on this script https://scriptrunner.adaptavist.com/5.5.7/jira/recipes/workflow/validators/validate-attachments-links-in-transition.html
B.R.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.