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
Its Not working for me. Do we have any sample code for help?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.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", "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)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
is it possible via javascript?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Will script runner plugin be used instead of Behaviours plugin?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It wont be possible via javascript since the status is not present on the screen/pop up
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Script runner cannot cannot be used to change the values of a dropdown on the screen , script runner can provide a post function which will set the value to the customfield based on status
Using behaviours plugin for this type of customization is better than pasting javascript in the fields description
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.