Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I'd rather not create different workflows for sub-tasks and Epics if I can help it. As such I'd like to have a simple groovy script that says
For these issue types ... if Epic Link is empty, return False.
Using Scripted (Groovy) Validator (JMWE add-on) I tried several different ways to get this to work. All failed. The piece I'm having trouble with is testing if Epic Link is empty.
Here's the last thing that didn't work.
if((issue.issueType.name == 'Improvement' || issue.issueType.name == 'New Feature') && !cfValues['epicLink']) { return false; } return true;
All help appreciated.
Hi,
You can try this code, it worked for me:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link')
def epic = issue.getCustomFieldValue(epicLink)
if((issue.issueType.name == 'Improvement' || issue.issueType.name == 'New Feature') && !epic){
return false
}
return true
Regards,
Marcos
When I test that within the validator creation page I get:
I'm using the JMWE scripted validator if it matters.
groovy.lang.MissingMethodException: No signature of method: script15245815380461398564983.mport() is applicable for argument types: (java.lang.Class) values: [class com.atlassian.jira.component.ComponentAccessor] Possible solutions: split(groovy.lang.Closure), wait(), every(), wait(long), print(java.lang.Object), main([Ljava.lang.String;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Maybe it's a copy-paste mistake...
I paste a screenshot of my configuration:
Regards,
Marcos
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.
Hi,
What's in line 1? The screenshot doesn't show it so I can't see all the code...
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HAH. Shut my mouth! I didn't save the last attempt. So I cut and pasted your solution again and it's working. Love it. THANK YOU.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hahaha!
It's nice to hear that it works!!
Have a nice day!
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
While I have someone that clearly knows what they are doing .... why can I not use the same code for "Original Estimate"? I'd like to require it for all but epics and bugs, but replacing 'Epic Link' with 'Original Estimate' does not work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Maybe you can try it this way:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def originalEstimate = issue.originalEstimate
if((issue.issueType.name == 'Epic' || issue.issueType.name == 'Bug') && !originalEstimate){
return false
}
return true
Hope it helps.
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're HIRED! :) Thank you. Works like a charm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome!
Have a nice day,
Marcos.
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.