Hi,
I'm attempting to write a simple validation script that fails the transition if a certain linked issue type is not present. Currently, the linked issue field is on the transition screen. I also have the Resolution field on the transition screen. Here is my script:
def resolution = issue.getResolution()
if (resolution.getName() == 'Duplicate') {
issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains("Duplicate")
} else {
return true;
}
I added logging and discovered aht the resolution.getName() is returning 'Duplicate', but the return from getOutwardLinks returns empty. I swapped out the getOutwardLinks method with the getInwardLinks method and the script behaves the same.
I think it's weird that the resolution field has the value that the user entered on the screen for the transition, but the linked issue value did not get updated.
Any suggestions?
It's quiet different from getting value of linked issue field(in current form/screen) from other fields
I'm attaching sample code for your reference(written sometime back you may need to correct/adjust something)
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
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.link.IssueLink
def fieldManager = ComponentAccessor.getFieldManager()
def linksSystemField = fieldManager.getField("issuelinks") as IssueLinksSystemField
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def request = ActionContext.getRequest()
if(issue.resolution.name =="Duplicate") {
if (request) {
def params = request.getParameterMap()
def issueLinkingValue = linksSystemField.getRelevantParams(params) as IssueLinksSystemField.IssueLinkingValue
if (! (issueLinkingValue.linkDescription == "duplicates" && issueLinkingValue.linkedIssues.size())) {
throw new InvalidInputException(IssueFieldConstants.ISSUE_LINKS,
"Note: You must use link type 'duplicates'.")
}
}
}
if you notice above I used request.getParamaterMap() method to get current screen's linked issue value
Hope it helps you
BR,
Leo
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.