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.
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.
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
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.