Hello all,
Within Behaviors, I'm trying to figure out how to pull the "Value" of the issue type field drop down within the create screen in order to set specific options within a single select customfield (Client).
So far I have this:
import com.atlassian.jira.component.ComponentAccessorimport com.onresolve.jira.groovy.user.FieldBehavioursimport groovy.transform.BaseScript@BaseScript FieldBehaviours fieldBehavioursdef IssueTypeField = #????#def IssueTypeFieldValue = #????#log.warn("issue type value = ${IssueTypeField}")def ClientField = getFieldByName("Client")def optionManager = ComponentAccessor.optionsManagerdef customFieldManager = ComponentAccessor.customFieldManagerdef ClientFieldCustomField = customFieldManager.getCustomFieldObject(ClientField.fieldId)def ClientFieldConfig = ClientFieldCustomField.getRelevantConfig(issueContext)def ClientFieldOptions = optionManager.getOptions(ClientFieldConfig)def allAppOptions = [ "Issue-Type-#1": ["Client A"], "Issue-Type-#2": ["Client A", "Client B"], ]if (allAppOptions[IssueTypeFieldValue]) { ClientField.setFieldOptions(allAppOptions[IssueTypeFieldValue])} else { ClientField.setFieldOptions([])}
Can someone help?
Thanks,
Mike
When you're on 'Create' normal field getters won't work, because the issue doesn't exist. There is a different way to get it by reading it off the current context:
def issueTypeName = getIssueContext().getIssueType().getName()
Which does change also if you switch issue types midway through the form.
Other than that, I'm not sure whether the way you're trying to set field options will work, this seems a bit sus with nested string lists:
def allAppOptions = [ "Issue-Type-#1": ["Client A"], "Issue-Type-#2": ["Client A", "Client B"], ]
If it doesn't, see https://docs.adaptavist.com/sr4js/latest/features/behaviours/api-quick-reference on how to get it to work.
Hi Radek,
The above code for the issue type name:
Worked like a charm, and so did the original "def allAppOptions" coding.
Thank you very much!
~Mike
It looks like you're new here. Sign in or register to get started.