I want to change drop down value of custom field based on status.For eg:If status is StatusA, then value in drop down should be A1,A2.If status is StatusB, then value in drop down should be A1,B1,B2.How can i achieve this?
You can use the JJupin plugin for that with its Live Fields fieature. Here's a similar example to what you're looking for:
http://confluence.kepler-rominfo.com/display/TR/Restricting+resolutions+based+on+issue+type
You can use Behaviours plugin for this , You will need to write a custom groovy script which will check for the status and display options in the required customfield .
refer the below docs for examples
https://jamieechlin.atlassian.net/wiki/display/JBHV/JIRA+Behaviours+Plugin
https://jamieechlin.atlassian.net/wiki/display/JBHV/Miscellaneous+Behaviours+Examples#MiscellaneousBehavioursExamples-Addorremoveoptionstosingleormulti-selectfields
is it possible via javascript?
Will script runner plugin be used instead of Behaviours plugin?
It wont be possible via javascript since the status is not present on the screen/pop up
hi!!
you can use Database Custom Field (https://marketplace.atlassian.com/plugins/com.keplerrominfo.jira.plugins.databasecf) and a auxiliar database table with the relationship between status and drop down field.
The database table will have the following values:
Status A - A1
Status A - A2
Status B - A1
Status B - B1
Status B - B2
So, the query will be dependant on status field :-)
Hope this helps.
Its Not working for me. Do we have any sample code for help?
You can use the below code in Behaviours which is part of Adaptivist ScriptRunner plugin:
Select the dropdown field and then add below serverside script:
import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager()def optionsManager = ComponentAccessor.getOptionsManager()def formField = getFieldById(getFieldChanged())def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())def config = customField.getRelevantConfig(getIssueContext())def options = optionsManager.getOptions(config)if (underlyingIssue.getStatus().getName() == "A") {def optionsMap = options.findAll {it.value in ["A1", "A2"]}.collectEntries {[(it.optionId.toString()) : it.value]}formField.setFieldOptions(optionsMap)}if (underlyingIssue.getStatus().getName() == "B") {def optionsMap = options.findAll {it.value in ["A1", "B1", "B2"]}.collectEntries {[(it.optionId.toString()) : it.value]}formField.setFieldOptions(optionsMap)}
You can achieve this using Behaviours with the below code. Behaviours is part of Adaptivist ScriptRunner plugin.Select the drop down field and add the below server side script:
import com.atlassian.jira.component.ComponentAccessordef customFieldManager = ComponentAccessor.getCustomFieldManager()def optionsManager = ComponentAccessor.getOptionsManager()def formField = getFieldById(getFieldChanged())def customField = customFieldManager.getCustomFieldObject(formField.getFieldId())def config = customField.getRelevantConfig(getIssueContext())def options = optionsManager.getOptions(config)if (underlyingIssue.getStatus().getName() == "A") { def optionsMap = options.findAll {it.value in ["A1", "B2"]}.collectEntries {[(it.optionId.toString()) : it.value]}formField.setFieldOptions(optionsMap)} if (underlyingIssue.getStatus().getName() == "B") { def optionsMap = options.findAll {it.value in ["A1", "B1", "B2"]}.collectEntries {[(it.optionId.toString()) : it.value]}formField.setFieldOptions(optionsMap)}
It looks like you're new here. Sign in or register to get started.