Pre-populate summary field

Hey guys,

I'm trying to populate the summary field in one issue type (not all), so that it does the following:

When users select "create issue" > "new starter form", the summary field will be pre-populated with "New Starter - Name - Due Date" (these aren't variables, or calculated entries, just standard text).

I've seen in http://jira.10933.n7.nabble.com/Can-I-populate-a-field-based-on-selection-of-another-during-Create-Issue-td25541.html that you can use a custom field to populate the summary field, but I can't seem to get this to work.

Any help would be great!

Thanks

Alex

4 answers

try with the following code, if you want to copy value from the other fields to summary field

<script type="text/javascript">
jQuery(document).ready(function($) {
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
		addSummary();
	});
	addSummary();
	
	function addSummary(){	
		var issueTypeCreate = $("#issuetype-field").val();
		var issueType = $("#issue-create-issue-type").text();
		if((issueTypeCreate != null && issueTypeCreate === "Bug") || issueType === "Bug"){
			//if you want hide summry field use this
			//$('#summary').closest('div.field-group').hide();
			
			$("#SVNKitNPIProjectSelect").change(function(){
				// use this if you want to copy value from select list field to summary field
				var selectList=$("#customfield_10407 option:selected").text();
				$("#summary").val(summaryValue);
				
				//or use this if you want to copy text field value to summary
				var textFieldVal=$("#customfield_13815").val();
				$("#summary").val(textFieldVal);
			});
		}
				
	}	
		
});
</script>


is this what your looking for you?

Heya,

Thank you for the assistance.

In regards to this, would I put this script in the summary field default value or in a custom message field (edit)?

Many thanks!

add the above script in custom field description in field configuration that issue type or you can add it to plugin as webresource module

check this post to know how to add it to plugin as web-resource module

https://answers.atlassian.com/questions/47843/strange-javascript-problem-in-create-screen

Seems that didn't work unfortunately.

I did however, find another method of doing it:

<script type="text/javascript">
if (AJS.$("#summary").val().length <= 0){
AJS.$("#summary").val("New Starter - Starter Name - Start Date");
}
</script>

Does this still work for you (what version of JIRA are you currently utilizing)?  I thought they were moving away from allowing scripting in the description of the field.

Hi, I'm new at all this scripting and am trying to format the Summary field.

I have 2 fields which the user fills out and I want to use those values to pre-populate the Summary field. How do I have to modify the above code in order to get it to work? I have the following 2 fields:
1) JProject
2) ATID

I want the Summary field to be formatted with the words "Access Request" followed by the value in JProject followed by the value in ATID. Could someone please help while I try to learn javascript?

Thanks.

Faisal,

You'd probably better off in the long term keeping the 3 pieces of information separate in the issue type field, JProject and ATID fields. Then display them next to each other in the columns of the issue navigator.

If you paste them altogether into one field someone is only going to ask you to parse that field later on, which will be tedious. Store the info in one place only

If you really have to have a read-only calculated field to show this then use the Script Runner add-on (not available inOnDemand)

~Matt

Hi Matt,

I did not know you could configure the Issue Navigator (I'm new at all of this). I'll look into it as it may be a good workaround for me.

Thank you for the suggestion.

I am trying to do the same thing, set the Summary from a custom field that is a select list.

I would like the summary to be what the selected text is.

I've looked at the above example and do not understand what I should change #SVNKitNPIProjectSelect to? I tried changing it to the name of the custom field and #customfield_10008 , but I cannot get it to work. The JavaScrpt runs up to the hiding of the summany.

Any insights would be appreciated.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

758 views 2 19
Join discussion

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