Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Auto-Populate Field in Issue Creation Screen

Ariel Rosa October 15, 2014

Hello guys,

I have two custom fields in issue creation screen, 'Field A' and 'Field B'.
I need a way to populate 'Field B' automatically after the user inputs the value in 'Field A'.

I know this can be achieved with Javascript, but since my knowledge in the area is limited, is there a tutorial or any tips that can help out?

I need to develop a separate plugin or can I just add the Javascript as html in the customfield config?


Thanks for any insights on this issue. 

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Ariel Rosa October 20, 2014

Done:

<script type="text/javascript">
    input = document.getElementById('customfield_12301');
    if (input) {
        target = document.getElementById('customfield_12300');
        input.onchange=function() {
            if (input.value == 11705) {             
                var valor = 11700;
			    target.value = valor;
            }
        }
    }
 </script>
0 votes
Michael Molina December 17, 2017

Hi Ariel,

is that also working with many fields? let say Field A will be populated when data has been inputted in Field B,C,D,E & F? Field A = summary details of fields B,C,D,E&F (this will be shown as the header of the whole). 

 

thanks,
Khel

0 votes
Ariel Rosa October 16, 2014

I'm trying something like:

 

<script type="text/javascript">   
jQuery(document).ready( function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e,context) {
    setFieldValues();
});
setFieldValues();
function setFieldValues(){
	output = document.getElementById('customfield_12301');
	if (output) {
		target = document.getElementById('customfield_12300');
  
		output.onchange=function() {
			if (output.value == 11705) {             
				var valor = 11700;
				setValue(target,valor);
            }
        }
    
    }
}
function setValue(field,value){
        $(field+" option").each(function() {
            if($(this).text() == value) {
                $(this).attr('selected', 'selected');           
            }                       
        });
         
    }
	});
</script>

but i keep getting the following error:

Uncaught Error: Syntax error, unrecognized expression: [object HTMLSelectElement]
Michael Molina December 17, 2017

Hi Ariel,

is that also working with many fields? let say Field A will be populated when data has been inputted in Field B,C,D,E & F? Field A = summary details of fields B,C,D,E&F (this will be shown as the header of the whole). 

 

thanks,
Khel

TAGS
AUG Leaders

Atlassian Community Events