Hello Team,
I am trying to create a workflow validator wherein it will check the status of the Epic issue type linked to the issue and ensures it is in either Open, In Progress or Ready statuses only. In case of any other status it should not allow the creation.
Below script is what i am using
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
def issueManager = ComponentAccessor.issueManager
// Get the Epic link issue
def epicLink = ComponentAccessor.issueLinkManager.getInwardLinks(issue.id).find { link -> link.issueLinkType.name == "Epic Link" }
if (epicLink) { def epicIssue = epicLink.sourceObject
// Check the status of the Epic issue
def epicStatus = epicIssue.getStatus().getName()
if (!["Open", "In Progress", "Ready"].contains(epicStatus))
{
return false
}
} return true
This is added in simple scripted validator by scriptrunner at the time of Issue creation.
But the script is failing to validate the condition i am looking for.
Can you let me know if i am making some mistake.
Thanks in advance.
Try this, checked it in my instance, it must work :)
/*
* Created 2023.
* @author Evgeniy Isaenkov
* @github https://github.com/Udjin79/SRUtils
*/
import com.atlassian.jira.issue.Issue
Issue epicIssue = cfValues['Epic Link'] as Issue
if (epicIssue) {
String epicStatus = epicIssue.getStatus().getName()
if (!(epicStatus in ["Open", "In Progress", "Ready"])) {
return false
}
}
return true
Perfect thanks @Evgenii -> @Sreedevi Raman Pisharody this is exactly what I was talking about earlier.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Evgeniy and Craig for your quick support, I tested it out and it worked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sreedevi Raman Pisharody it's Sunday, I don't have a test env. Was thinking wouldn't it be better to check the field for the epic link value instead of the inward link since the issue isn't created yet... again just a thought since I can't validate this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Appreciate you responding even on Sunday.
I will surely try to check it out and let you know.
Again thanks for your response.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear @Sreedevi Raman Pisharody
As @Craig Nodwell said, the issue is not created yet. So it doesn't have an ID yet.
As workaroud, I gess to use the following line of code instead of using issueLinkManager
def epicLink = issue.getAllOutwardLinks().find { link -> link.issueLinkType.name == "Epic Link"}
Best Regards,
Seif,
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.