Thanks to what Henning and Jamie have helped here: https://answers.atlassian.com/questions/139592, I know how to validate if the current issue has a duplicate link to another one (called parent)
Now, on top of that, I need add an additional checking that the parent that user has specified for this link should NOT be a duplicate of another parent.
This sounds easy since I thought I could just get the Id of the parent issue of the link and check its own OutwardLinks to see if any of them is also Duplicate, something like this:
linkCnt = 0
request = webwork.action.ActionContext.getRequest()
if (request) {
// check for new duplicates link
linktype = request.getParameter('issuelinks-linktype')
linkedIssue = request.getParameter('issuelinks-issues')
if (linktype == 'duplicates' && linkedIssue)
{ //----- This is the additional checking
if(! issueLinkManager.getOutwardLinks(linkedIssue.getId())*.issueLinkType.name.contains('Duplicate') )
linkCnt = 1
}
}
// check for existing duplicates link
if ( issueLinkManager.getOutwardLinks(issue.getId())*.issueLinkType.name.contains('Duplicate') ) linkCnt += 1
// Transition requires at least one duplicates link
(linkCnt>=1)
But this doesn't work correctly. I guess that it's because of
linkedIssue.getId()
doesn't give me the correct Id of the parent (destination) issue of the link.
What is the correct function to use here to make this works?
Thanks
Hung