Hi all,
I need to add a scriprunner validator in the Create linked issue function to check the status of the linked issue.
Is it possible to do it?
The problem is that in the validation phase, I cannot get any linked issue. Maybe this is a two phase function, where in the first the issue will be created and in the second the link will be added?
This is the function thai I use to get the linked issue by link name:
def getInwardIssueList(linkType, issue) {
def result = new ArrayList();
List<IssueLink> allInIssueLink = ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId());
for (Iterator<IssueLink> outIterator = allInIssueLink.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
//log.error(issueLink.getIssueLinkType().getName())
if (issueLink.getIssueLinkType().name == linkType) {
//def linkedIssue = issueLink.getDestinationObject()
def linkedIssue = issueLink.getSourceObject()
String type = linkedIssue.getIssueType().getName();
result.add(linkedIssue);
}
}
return result;
}
Correct, the "Create Issue Link" appears to act as a wrapper between two other user tasks.
1) Create an issue (with access to validators, post function and everything else in the workflow)
2) Create an Issue Link (which doesn't execute any workflow feature).
With scriptrunner, you can create a listener that will check for IssueLinkCreatedEvent, but you can't interrupt the link creation. The issue has long since been created and the link creation is also complete.
At this point, if your validations fail, you can 1) delete the link, 2) Comment on the source or target issue.
Another option would be to subvert the "create issue link" function completely (hide it with a scriptrunner fragment) and add a workflow transition that will clone the issue using a post function. There, you will have the opportunity to validate some input and decide whether to allow cloning and linking to proceed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.