I've a custom field with Select List (single choice) where i want to add / remove values based on issue type.
can someone help me on this ?
Adding my code below :
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.component.ComponentAccessor
def cfManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def multiSelectCF = cfManager.getCustomFieldObjectsByName("Component")[0]
def formMultiSelect = getFieldById("customfield_15200")
def singleSelectValue = getIssueContext().getIssueType().name
def config = ComponentAccessor.fieldConfigSchemeManager.getRelevantConfig(issueContext, multiSelectCF)
def options = optionsManager.getOptions(config)
def Bug = ["A","B"]
def Story = ["B","D"]
def Epic = ["A","B","C","D"]
switch(singleSelectValue)
{
case "Bug":
formMultiSelect.setFieldOptions(options.findAll{it.value in Bug}.collectEntries{[(it.optionId): it.value]})
break
case "Story":
formMultiSelect.setFieldOptions(options.findAll{it.value in Story}.collectEntries{[(it.optionId): it.value]})
break
case "Epic":
formMultiSelect.setFieldOptions(options.findAll{it.value in Epic}.collectEntries{[(it.optionId): it.value]})
break
default:
formMultiSelect.setFieldOptions(options)
}
Thanks,
Krishna
Looks like you're heading down the right path; what are you experiencing that indicates that it is not working as you expect?
Hi @Payne ,
Thanks for responding.
Actually i fixed it myself after some digging up.
There was another behaviour for the Component field. which created dependency for the field.
So i merged the both codes. Now its working as expected.
Regards,
Krishna
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.