Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Open another field according to a certain choice

Lior Pesoa October 16, 2011

Hi,

I would like to be able to open another field according to a ceratin choice.

For example:

Resolving a bug screen. you can choose from a multiple options (Fixed, Won't Fix, Not a Bug, Duplicate, etc...)

Lets say you choosed "Duplicate"

If you choose "Duplicate" i want a new field to be opened - "Linked Issues" so you can link the current issue the the duplicated one.

The "Linked Issue" field will be hidden in the screen and will appear only if you choose "Duplicate".

1 answer

1 accepted

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2011

You can do all this with javascript but in my opinion it's fragile, likely to break when jira is upgraded, and difficult to test due to the fact that custom field IDs will invariably be different from dev to uat, and uat to prod.

If you use the behaviours plugin you can add a new behaviour, add the Resolution field, click "add server script", paste in:

FormField res = getFieldById(getFieldChanged())
FormField links = getFieldById("issuelinks")
if (res.getFormValue() == "3") { // duplicate
    links.setRequired(true).setHidden(false)
    if (! links.getFormValue()) {
        links.setHelpText("Please enter the duplicated issue.")
    }
}
else {
    links.setHelpText("")
    links.setRequired(false).setHidden(true)
}

then apply the behaviour to the project.

BTW, support for the "issue links" system field was only added recently, I have not tested much.

Lior Pesoa October 16, 2011

Working like a charm!

If anyone else want to use it, just don't forget to add the "Linked Issues" field to the desired screen.

Lior Pesoa October 16, 2011

One more thing, for some reason the field is "Required"

although i didn't set it to be (i want it to be "Optional")

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events