Custom Field - Yes/No: Can I have another Custom Field appear if 'Yes' is chosen?

Jill Pate June 18, 2012

I created a Custom Field with 'Yes' and 'No'. I want additional information if they choose 'Yes', but I would prefer if that field didn't always show, so I would like to configure it that a new field appears if 'Yes' is chosen - otherwise it is hidden.

Thank you

3 answers

1 accepted

0 votes
Answer accepted
Mizan
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.
June 18, 2012

Try adding Javascript in the desciption of the customfield in Field configuration.

The Javascript will check the yes/no customfield and based on this show/hide another customfield

Have a look at this example

0 votes
Justin Corcoran
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.
June 18, 2012

Check out the Behaviours Plugin: https://studio.plugins.atlassian.com/wiki/display/JBHV/Miscellaneous+Behaviours+Examples#MiscellaneousBehavioursExamples-Showorhidefields

Although on further inspection, I see you're using On Demand. I have no idea if this works with On Demand.

Mizan
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.
June 18, 2012

Behaviours not available on Ondemand

0 votes
grundic
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.
June 18, 2012

Here is example, how you can do that. You don't need custom field. Just add some javascript code to show/hide custom field you are interested in.

Hope, it helps.

Jill Pate June 18, 2012

This is great if I knew javascript code.

grundic
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.
June 18, 2012

Well, it's not very complex language and there are a lot of examples on the web.

Also, there is excelent plugin for Firefox - Firebug. With it's help you can run and test any clause or expressions right on web page!

So, I suggest to read about it a little bit and try it out.

Jill Pate June 19, 2012

Thank you.

I am having a problem finding the custom field id. When I hover over the Edit button for my custom field, the path referenced 'EditDefaultFieldLayout'.

Jill Pate June 19, 2012

I finally found the ID!!!

This is what I want:

If Related to Another Issue field (which is defaulting to None), is chosen, when hide the Issue Number field.

This is what I have:

<script type="text/javascript">

radiobutton = document.getElementById('customfield_10208');

target = document.getElementById('customfield_10209');

// Hide the target field by default

target.style.display = 'none';

radiobutton.onclick=function() {

if(radiobutton(‘RelatedtoAntoherIssue_None’).checked) {

target.style.display = '';

} else{

target.style.display='none';

}

};

</script>

Question 1: do I place this in the Description for the Source or Target?

Question 2: what is wrong? Why doesn't this work?

grundic
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.
June 19, 2012

>> Question 1: do I place this in the Description for the Source or Target?

Yes, you place javascript code rigth in discription of field

Question 2 is more tricky. I would suggest to use Firebug with it's console. You can execute scripts in browser and see result. Also, there is handy function console.log("some text")

Also, instead of using document.getElementById('#some_id') you can you jquery function AJS.$('#some_id') (AJS is Atlassian namespace, where jquery is declared).

Check jquery docs - it's more easier to write scripts with help of this great library!

Suggest an answer

Log in or Sign up to answer