Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scripted field for status of Epic

Jeroen van der Veen August 1, 2019

I want to have a scripted field in my development tickets which can show me the current status of the linked Epic. This can help me create an overview for my releases.

We have Scriptrunner , JCMF and Automation for Jira.

I have looked at a lot of scripts through this forum, but none which does the trick for me.

Help would be greatly appreciated!

 

2 answers

1 accepted

4 votes
Answer accepted
PD Sheehan
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.
August 1, 2019

Assuming you want the workflow status of the epic (and not the internal epic status (new/in progress/done) ... you can do the following using a scriptrunner custom scripted field:

Give your new field a name: Status Of Epic

Set template = Custom

Put the following in the template:

#set ($componentAccessor = $constantsManager.getClass().forName('com.atlassian.jira.component.ComponentAccessor').newInstance())
#set ($cfManager = $componentAccessor.customFieldManager)
#set ($epicLinkField = $cfManager.getCustomFieldObjectByName('Epic Link'))
#set ($epic = $issue.getCustomFieldValue($epicLinkField))
#set ($status = $epic.status)
<span
class="jira-issue-status-lozenge aui-lozenge
jira-issue-status-lozenge-$status.statusCategory.colorName"
data-tooltip="
<span class=&quot;jira-issue-status-tooltip-title&quot;>
$status.descTranslation
</span>
"
>
$status.nameTranslation
</span>

Then in the Inline Script:

import com.atlassian.jira.component.ComponentAccessor
def cfManager = ComponentAccessor.customFieldManager
def epicLinkField = cfManager.getCustomFieldObjectByName('Epic Link')

def epic = issue.getCustomFieldValue(epicLinkField)
epic.status.name

 If you don't care about displaying the status like it does for the current issue (with lozenge and color) then your can just set template=text

Jeroen van der Veen August 2, 2019

Thanks a bunch, exactly what I was looking for and works like a charm!

StayAtHome November 6, 2020

Perfect!

Nhac Tat Nguyen
Contributor
May 4, 2021

@PD Sheehan will this works with JQL search?

PD Sheehan
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 5, 2021

Yes, but with some limitations.

A scripted field on issue A based on status in Issue B will be calculated and added to index when A is changed or indexed.

If issue B changes status, the indexed data will be stale (still have the old value) until issue A is updated/indexed again.

TSD Group July 6, 2022

@PD Sheehan thanks for this! Really helpful!

0 votes
Pete Singleton
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.
August 1, 2019

If you want to show the field on the children of the Epic, you can use the JMCF custom field "Parent Status Field".  

Jeroen van der Veen August 2, 2019

I've tried this, and found I only got the status for parents of Sub-tasks.

The use case I have is for stories/bugs.

Suggest an answer

Log in or Sign up to answer