Custom fields on create screen

Natalia Torres June 16, 2014

Hi everyone,

When I create an issue I add a select list custom field. Depending the user selected option I need extra information so I need show different custom field (with diferent field types). I find documentation that explains how using javascript on the description custom fields you can hide it but the associated label is showed always on my jira version (5.2.11).

There any way to do this? I think about other solutions but i don't know if exists any. For example, Can I show automaticatly other screen after creation (configuring which screen depending the option selecten on custom field) and put in this more custom fields related with the first one?

Thanks

4 answers

1 accepted

0 votes
Answer accepted
eric anier
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.
July 6, 2014

Hi,

try the script below, this is exactly how we use it, just replace the customfield with the correct value

<script type="text/javascript">

	function selectedCorrectItem(){
		var controlCustomField = document.getElementById('customfield_10000');
		for (x=0;x<controlCustomField.length;x++){
			if (controlCustomField.options[x].selected) {
				if (controlCustomField[x].value == 'id_value'){
					return true;
				}
			}
		}
		return false;
	}
	
	controlCustomField = document.getElementById('customfield_10000');
		toHideCustomField = document.getElementById('customfield_10001');
		controlCustomField.onchange=function() {
			if (selectedCorrectItem()) {
				toHideCustomField.parentNode.style.display='';
			} else {
				toHideCustomField.value ='';
				toHideCustomField.parentNode.style.display='none';
				}
		}
 </script>

Natalia Torres July 7, 2014

Thanks Eric, I test it and it works fine

0 votes
Theinvisibleman
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 16, 2014

Hey Natalia,

Could setting different screen schemes with different issue types work to suit your requirements? You can check out more about Issue Type Screen Schemes here - Associating Screen and Issue Operation Mappings with an Issue Type

Natalia Torres July 6, 2014

Hi,

i read it when i was thinking how to do this. The problem is that for each issue type i need a list of "standard requests" for my project (a list). Some of the options on this "standard requests" need different extra information.. for example for the option A I need to fill a text field, for the option B I need to show a select list, etc.

Any suggestion how i can do this,

thanks

0 votes
Nadir MEZIANI
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 16, 2014

Hi,

Javascript is not recommended, but I think you forgot to install a node, parent node to hide the div Which Contain label and value.

can you post your script or an example?


Natalia Torres June 16, 2014

Hi,

i know that javascript is not recomended but i don't find other way to do this after readind documentations and searchin on answers.

Here an example that when I chose one priority option I show a custom field that works but the label of the custom field is always showed:

<script type="text/javascript">

priority = document.getElementById('priority');

if (priority) {

target2 = document.getElementById('customfield_11001');

if (priority.value != 2) target2.style.display='none';

priority.onchange=function() {

if (this.value == 2) {

target2.style.display = '';

target2.value="enter message here for field camp11";

} else {

target2.style.display='none';

}

}

}

</script>

Nadir MEZIANI
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 17, 2014

Hi,

Try this script

&lt;script type="text/javascript"&gt;
	AJS.$(document).bind('dialogContentReady', function(event, dialog) {
		priority = AJS.$('#priority');
		target2=AJS.$('#customfield_11001');
		if(priority.length&gt;0){
			if(priority.val!=2){
				target2.closest('div.field-group').hide();
			}
			priority.change(
				function(){
					if(priority.val()==2){
						target2.closest('div.field-group').show();
						target2.val('enter message here for field camp11');
					}
					else{
						target2.closest('div.field-group').hide();
						target2.val('')
					}
				}
			);
		}
	});
&lt;/script&gt;

Natalia Torres July 6, 2014

Thaks, I test it but it doesn't works

Nadir MEZIANI
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.
July 7, 2014

Hi, what is the error ?

0 votes
Vijay Khacharia
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 16, 2014

Hi Nataila,

Not sure if it would help. But try the suggetion in link below.

http://stackoverflow.com/questions/17233782/how-to-create-cascade-multiple-select-list-custom-field

Vijay

Natalia Torres June 16, 2014

Thanks but i think i doesn't work because in some cases when I choose an option from the first select I need 3 or 4 custom text field, but selectin other option maybe I nedd another select list.

The custom fieds need depend which select option you choose.

Suggest an answer

Log in or Sign up to answer