Validating linked issue key fails during issue creation but test is ok

Dominik Dünnebacke May 10, 2022

Hi!

I'm trying to set up a 'Scripted (Groovy) Validator (JMWE app)' validator that checks if an issue of a certain project key was linked during creation of the issue. My script works fine when I test it against an existing issue in the editor, but fails to work during creation.

Any help would be greatly appreciated.

This is the script:

import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager

// Collect project keys of all linked outgoing issues
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def linkedKeys = issueLinkManager.getOutwardLinks(issue.id).destinationObject.projectObject.key

// Check if linked keys contains a DPO ticket
linkedKeys.contains("DPO")

 These are the validator settings with a successful test of an existing issue:

chrome_tR5ijsYryu.png

Error message on form even though a DPO ticket is linked:

dHmo1z1GyM.png

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2022

Hi @Dominik Dünnebacke ,

I recommend you use the Related Issue Validator instead, which will take care of differentiating issue links added on the transition screen from pre-existing issue links.

image.png

Best,

David

Dominik Dünnebacke May 10, 2022

That works, thanks a lot! :-)
I found one contraint though: I can only link DPO issues now. Ideally I would like to allow other issues to be linkable as long as one DPO issue is linked.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2022

Did you try unchecking the "All related issues must verify the condition above" option?

Dominik Dünnebacke May 10, 2022

Once again that fixed it. Thanks @David Fischer !

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2022

Great!

Can you "accept" the answer so that others can find it?

Suggest an answer

Log in or Sign up to answer