It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Validator Scipt Missing LinkedIssues Updates Made From

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?

1 answer

0 votes
Leo Community Leader Nov 21, 2019

Hi @Edward Greathouse,

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

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you