Hello community,
How to update custom field value, when i change the issue type value?
exempl: if I select the "Traitements" issue type, I want the list ["Contrôles C8", "Alimentation VL", "Derniers acquittements", "Etats PXP"] displayed in the custom filed "Sub-task type"
if I select the "OST" issue type, the list ["Remboursement final / anticipé", "Fusion absorption", "Division / Regroupement", "Coupons / dividendes", "Changement de nom / codes ISIN"] is displayed.
I created the script below but it didn't work
could you help me!
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def constantsManager = ComponentAccessor.getConstantsManager()
def SubTaskType= getFieldById("customfield_14650")
def SelectedIssueType = getFieldById("issuetype").getValue()
def traitementIssueTypeList = constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Contrôles C8", "Alimentation VL", "Derniers acquittements", "Etats PXP"]
[(it.id): it.name]
}
def ostIssueTypeList = constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Remboursement final / anticipé", "Fusion absorption", "Division / Regroupement", "Coupons / dividendes", "Changement de nom / codes ISIN"]
}.collectEntries {
[(it.id): it.name]
}
def regularisationIssueTypeList = constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Rappro AXA SL", "Rappro AZ"]
}.collectEntries {
[(it.id): it.name]
}
def paramIssueTypeList = constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Fonds", "Fonds structurés et avenants"]
}.collectEntries {
[(it.id): it.name]
}
def projetIssueTypeList = constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Amélioration process", "EDB"]
}.collectEntries {
[(it.id): it.name]
}
def baseDocIssueTypeList = constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["Procédures", "Process", "Mode opératoire"]
}.collectEntries {
[(it.id): it.name]
}
def recetteIssueTypeList = constantsManager.getAllIssueTypeObjects().findAll {
it.name in ["PREP", "SIMU"]
}.collectEntries {
[(it.id): it.name]
}
if (SelectedIssueType== "Traitements")
{
SubTaskType.setFieldOptions(traitementIssueTypeList)
}
else if (SelectedIssueType== "OST") {
SubTaskType.setFieldOptions(ostIssueTypeList)
}
else if (SelectedIssueType== "Régularisation") {
SubTaskType.setFieldOptions(regularisationIssueTypeList)
}
else if (SelectedIssueType== "Paramètrage") {
SubTaskType.setFieldOptions(paramIssueTypeList)
}
else if (SelectedIssueType== "Projet") {
SubTaskType.setFieldOptions(projetIssueTypeList)
}
else if (SelectedIssueType== "Base documentaire") {
SubTaskType.setFieldOptions(baseDocIssueTypeList)
}
else if (SelectedIssueType== "Recette") {
SubTaskType.setFieldOptions(recetteIssueTypeList)
}
Best regards,
Eya