Auto-Populate Field in Issue Creation Screen

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

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>

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]

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

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
Community showcase
Posted yesterday in United States

Confluence Security Advisory

Good morning Members, Not sure if you are aware. Please read the following: https://www.icloud.com/keynote/0RyJ4VEdNUpjDpGfMhfZx9fEg#Confluence_Security_Advisor More details: https://co...

35 views 1 0
View post

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you