Hi,
I need to add a Transition validation that checks if all the Linked Issues are in a done status category, if found this code:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.link.IssueLink import com.opensymphony.workflow.InvalidInputException import org.apache.log4j.Logger import org.apache.log4j.Level def linkMgr = ComponentAccessor.getIssueLinkManager() for (IssueLink link in linkMgr.getInwardLinks(issue.id)) { log.info(link.sourceObject.resolutionId) if (!link.sourceObject.resolutionId) { return false throw new InvalidInputException("Issue Links must be close before continue") } }
But it only works on Condition, I need to set it on Validation to show the error message.
Any suggestion?
I'm very basic on Groovy
You can use the "simple scripted validator" for this.
I would write the condition like this:
import com.atlassian.jira.component.ComponentAccessor
def linkMgr = ComponentAccessor.issueLinkManager
linkMgr.getLinkCollection(issue, currentUser).allIssues.findAll{it != issue}.every{it.resolution}
It works perfectly. Thanks so much Peter-Dave.
Just a side note: I just noticed when you have a Condition for pending approval, the validation is skipped and don't performed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @PD Sheehan , what if I have to restrict this validator only to a specific request type. Is it possible? If so can I please know how can we do that.
Thanks Much
Abhi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Service Desk Request type? Or did you mean issue type?
And do you mean only validate linked issues if the current issue is of a specific type? Or only prevent closing the current issue if linked issues of a specific type are still open (ignore the status of other linked issues)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Daniel Alonso when using it with Validators, you should throw or set InvalidInputException to invalidInputException property. But you have "return false" code on the line before throwing exception, so it will never throw an exception.
Fix for validator is:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
import com.opensymphony.workflow.InvalidInputException
import org.apache.log4j.Logger
import org.apache.log4j.Level
def linkMgr = ComponentAccessor.getIssueLinkManager()
for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
log.info(link.sourceObject.resolutionId)
if (!link.sourceObject.resolutionId) {
throw new InvalidInputException("Issue Links must be close before continue")
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Something like this should work:
import com.atlassian.jira.component.ComponentAccessor
def linkMgr = ComponentAccessor.issueLinkManager
linkMgr.getLinkCollectionOverrideSecurity(issue).getOutwardIssues('is contained in').every{it.resolution}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you.
But it doesn't work the way I wanted.
When issue B is created in issue A, the linkedtype of issue A is "contain" and the linkedtype of issue B is "is contained in"
I want a validation that issue A can be compledted when status of issue B is "completion"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was wrong about the way "getOutwardIssue" works... you need to provide the name of the link type, not the outward description.
For example, I have a link type called "Requires". The outward description reads "requires" and the inward reads "is required by". So in my case, I can return the issues with
linkMgr.getLinkCollectionOverrideSecurity(issue).getOutwardIssues('Requires')
I don't know what your link type name is, you'll have to figure that out. But assuming it's something like "Contains" and the status you are looking for is exactly "completion" you can try this:
import com.atlassian.jira.component.ComponentAccessor
def linkMgr = ComponentAccessor.issueLinkManager
linkMgr.getLinkCollectionOverrideSecurity(issue).getOutwardIssues('Contains').every{it.status.name == "completion"}
This will return false if any of the "Contains" linked issue is not in status "completion" and cause the validator to fail.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, but issue A is completed even though issue B is not in the "Completion" status.
Below image is issue A, and link type is "contains" with issue B.(ENMCOMM-269). When I click "complete" button to completion, it should not be changed to "completion" status because status of issue B.(ENMCOMM-269) is not "completion"
Workflow is like below.
However issue A is completed even though issue B is not in the "Completion" status.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you include your complete script as it currently stands?
Also, a screenshot of the "Issue Linking" page showing your "contains" link type. I need to see all 3 elements: "Name", "Outward Description" "Inward Description"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just replace "Contains" with "Hierarchy link (WBSGantt)" in the script and if should do what you want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.