It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Auto-Populate Field in Issue Creation Screen

Ariel Rosa Oct 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

0 votes
Answer accepted
Ariel Rosa Oct 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
Ariel Rosa Oct 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 Dec 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
Michael Molina Dec 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

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

1,095 views 13 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you