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.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

in create validator want to require an Epic Link for only some issue types

Karla Russell April 24, 2018

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.

2 answers

1 accepted

0 votes
Answer accepted
Marcos Sanchez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2018

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

Karla Russell April 24, 2018

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;)
Marcos Sanchez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2018

Hi,

Maybe it's a copy-paste mistake... 

I paste a screenshot of my configuration:

 

2018-04-24_17h13_06.png

 

Regards,
Marcos

Karla Russell April 24, 2018

Screen Shot 2018-04-24 at 11.25.18 AM.png

Marcos Sanchez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2018

Hi,

 

What's in line 1? The screenshot doesn't show it so I can't see all the code...

 

Regards,

Marcos

Karla Russell April 24, 2018

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.

1 vote
Marcos Sanchez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2018

Hahaha!

It's nice to hear that it works!!

 

Have a nice day!

Marcos

DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2018

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. 

Marcos Sanchez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2018

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

DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 10, 2018

You're HIRED!  :)  Thank you.  Works like a charm.

Marcos Sanchez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 10, 2018

You're welcome!

Have a nice day,
Marcos.

Suggest an answer

Log in or Sign up to answer