Hi Community,
I need your help with the following scenario:
I have 2 custom fields ("Application" (15401) (Select List (Single Choice) and "Application Role(s)" (15400) (Select List (Multi Choice).
The field "Application Roles(s)" around 1000 options starting with a defined prefix ("SAP MDG*" or "SAP S/4HANA*").
Now I want to implement a scriprunner behaviour showing certain values in Application Role(s) (15400) and in the past (for fields with lower amount of options), we code like below:
{code}
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
// Get the fields
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def optionsManager = ComponentAccessor.getOptionsManager();
def Field2 = customFieldManager.getCustomFieldObject("customfield_15400")
def Field2_config = Field2.getRelevantConfig(getIssueContext());
def Field2_options = optionsManager.getOptions(Field2_config);
def Field2field = getFieldById("customfield_15400");
def Field1field = getFieldById("customfield_15401");
def Field1Value = Field1field.getValue()
if (Field1Value == null) {
Field2field.setHidden(true)
Field2field.setRequired(false)
}
else {
Field2field.setHidden(false)
Field2field.setRequired(true)
}
def AllowedValue = [ ]
if (Field1Value == "SAP Master Data Governance (MDG)"){
AllowedValue = ["SAP MDG_CONTROL EQUIPMENT - Category Approval","SAP MDG_CONVEYORS- Category Approval"]
} else if (Field1Value == "SAP S/4HANA"){
AllowedValue = ["SAP S/4HANA_ALM: Asset Operations Administrator (Asset) - SO 1010","SAP S/4HANA_ALM: Asset Operations Administrator (Asset) - SO 1030"]
} else if (Field1Value != "SAP Master Data Governance (MDG)" && Field1Value != "SAP S/4HANA") {
AllowedValue = ["N/A","Others"]
}
Field2field.setFieldOptions(Field2_options.findAll{it.value in (AllowedValue)})
{code}
As the field "Application Role(s)" has around 1000 options, I was wondering if and how the line with "AllowedValue" can be setup in such a way, that it searches for the options to display based on their Prefix (either "SAP MDG*" or "SAP S/4HANA*") ?
I'm looking forward for your response and help.
Kind Regards,
Stephan