Hi,
I want to block Task B from closing till Task A is not closed. How to achieve this using validator script runner?
Thanks
Swarna
Hi @Swarna Radha
what is the relationship between the issues? Linked? Parent-subtask?
Hi @Swarna Radha,
are those task linked each others? If yes, your validator should retrieve link and the related task associated. After doing that you need to check the status of Task A and, based on that, define if task B can be closed.
Do you need the code?
Both tasks are linked "is blocked by".
If possible can you please send me the code?
Another issue: If task is blocked that is it cannot transition. Can their subtasks be blocked also?
please try this code for your validator :
import com.atlassian.jira.component.ComponentAccessor;import com.atlassian.jira.issue.link.IssueLink;import com.atlassian.jira.issue.link.IssueLinkManager;import com.atlassian.jira.issue.Issue;IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager();List<IssueLink> issueLinks = issueLinkManager.getInwardLinks(issue.getId());for(IssueLink il : issueLinks){if(il.getIssueLinkType().getName().equals("is blocked by")){Issue source = il.getSourceObject();if(!source.getStatusObject().getName().equals("Closed")){throw new InvalidInputException("This task is blocked by "+source.getKey());}}}
@Fabio Racobaldo _Catworkx_ Thanks for the code.
Would be possible to block subtask from transitioning if parent task is blocked?
Yes, it is. Please try this code and let me know. For the other we need just to add a line
Hi @Fabio Racobaldo _Catworkx_
Getting on this line "throw new InvalidInputException("This task is blocked by "+source.getKey());"
It looks like you're new here. Sign in or register to get started.