My problem is pretty simple. I want a pull-down for states, and a pull-down for counties within the state (US states for this example) within a JIRA issue that updates when the state changes. I can get a json blob of the county-to-state maps that looks something like this:
[
{
stateName: "Texas",
stateAbbr: "Tx".
counties: [ "Anderson", "Andrews", Angelina",...]
}
{
stateName: "Oklahoma",
stateAbbr: "Ok",
counties: [ "Adair", "Alfalfa", "Atoka",...]
}
...
]
Obviously I've got all the counties, etc. in there. I've got a Adaptavist Script Runner plugin that pulls the list of states (some projects/issue types maybe use other countries, etc.), but how do I get the list of the counties to update when the state changes?
I'd prefer to have one call up-front when the JIRA issue creation screen loads instead of calls on the backend when people select different states. I can easily store all the states and counties in memory if I know how/where to get them.
Yes, this is a contrived example, but it represents a real problem. A "state/county" plugin isn't what I actually need. Groovy code that let's me save the counties for each state in a map and have the county choices update when the state changes is what I'm after. Thanks for any help you can provide.
Hello @Jared Hodge
Could you please elaborate a bit more on your requirement and especially the need to write code, because this is something supported out of the box by JIRA by means of "cascading select" custom field. In the custom field admin section you should be able to add a new custom field of type Cascading type which has first list as States and second list as counties and counties drop-down is updated as per the section of the State in the first drop-down.
I think he doesn't mean to have it configured in a default field, but auto populating it.
I don't know what the benefit is though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since the states and counties won't change thus better to have an pre-filled list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Agree.
And the project variable can easily be configured using Field Contexts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So this is a bit of a contrived example. Let's assume that the states and counties could vary from minute to minute or day to day. I want to make sure each time someone submits a request, they have the most recent list to pick from.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, that narrows it down a bit.
Either you need to do some coding so that your external feed of this variable data updates the options in a cascading select, or you should get one of the "database fields" add-ons and point that at the variable list, instead of the static ones Jira implements.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, no real way to do this with a behavior (how I've currently coded the state selection), but instead have a more static cascading option set that I update? One other wrinkle, different projects may have different sets of states (again, sorry this is a contrived example).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, you can't do it with a Behaviour. Those change the way existing data for a field works, but it can't change the way a field works underneath everything. A cascading select is a pair of lists of pre-filled options. If you wanted to update that list, you have to do it by making admin changes, you can't do it from a create/edit screen (Only lables accept new options in create/edit).
You can do different lists by project, either with field context, or by having a big long list and using Behaviours to drop items out dependent on the project
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The cascading fields doesn't quite do what I need. For instance, I need to limit the countries based on the project selected (again, sorry but a contrived example). Also, the cascading fields are not formatted in a very friendly way. It would be better if I could label each level, etc.
Any suggestions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One different approach might be using Insight as an asset repository and adding 2 insight fields, the 2nd being depended on the first.
Object would be linked, i.e countries are linked to the state.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.