Forums

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

How do you remove a closed JIRA epic for the list of Epic links?

Paul White
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 6, 2018

I read the similar questions and work around from 2 years ago but no solution has been proposed.  This is still very annoying to my team as we work through several closed Epics.  The list will continue to grow as we go froward and will become even more annoying.  Once the Epic is closed (and all related stories closed), how do we not see that Epic link when creating a new story?

We have reasons for keeping all closed stories and epics avail and the copy it off to a backup workaround is not acceptable to our team.  Thank you very much.

1 answer

1 accepted

1 vote
Answer accepted
Jonny Carter
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 Champions.
July 10, 2016

The simplest way to erase the field would be

def componentsField = getFieldById(COMPONENTS)
componentsField.setFormValue([])

Be forewarned, that will erase all components, including those set by the user and ones you aren't interested in changing. For example, let's say you also had the components Apple and Pie. You wouldn't necessarily want to wipe those on a change of a radio button. If you need, you could get the existing values, and use those in each set operation.

def existingValues = componentsField.getValue()
if (radioButtonCustomField == "whatever") {
componentsField.setFormValue(components.findAll { it.name in ["Orange", "Vert"] || it.id in existingValues }*.id)
}
else {
    componentsField.setFormValue(existingValues.removeAll(it.name in ["Orange", "Vert"]))
}

You may or may not need to do that, depending on your context.

Rambo
Contributor
July 11, 2016

Hello jcarter!

I tried the script, but the values "Orange" and "Green" doesn't seems to disappear in my creation screen when I click on an other value than "Blue" (with the radio button).

Is there an error on this script ??

------------------------------------------------------------------------------------------------------------------------------
import com.atlassian.jira.component.ComponentAccessor
 
import static com.atlassian.jira.issue.IssueFieldConstants.*
 
// set Components
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id)
def componentsField = getFieldById(COMPONENTS)
def existingValues = componentsField.getValue()   
    
FormField radio = getFieldByName("Button_Radio")
 
if(radio.getValue() == "Blue") // click on the “Blue” value in the "Button_Radio"
{
componentsField.setFormValue(components.findAll { it.name in ["Orange", "Green"] || it.id in existingValues }*.id) //set “Orange” and “Green” in the component field
}
else
{
componentsField.setFormValue(existingValues.removeAll(it.name in ["Orange", "Green"])) //remove “Orange” and “Green” in the component field
}
Jonny Carter
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 Champions.
July 11, 2016

The Groovy collection method removeAll actually returns a boolean and mutates the original collection. So you'll need to either replace it with a findAll and negate your condition

existingValues.findAll{!(it.name in ["Orange", "Green"])}

or do the removeAll on a separate line. Don't for get to add the *.id aggregator either, as setFormValue for components takes a list of IDs, not component objects.

Rambo
Contributor
July 11, 2016

Hello jcarter, I finaly manage the situation with your two solutions.

But the solution doesn't work with an user account (only with my administrator account). That's why it wasn't working when I answered you. Have you an idea of what could I do for that ??

Thanks again for your involvement

Rambo
Contributor
July 12, 2016

Problem solve! It don't work because I used ineternet explorer in my user account. No problem with modzilla. Thank you!

Suggest an answer

Log in or Sign up to answer