Pre-populate summary field

IT Support July 16, 2013

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

1 vote
RambanamP
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 16, 2013

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>


RambanamP
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 16, 2013

is this what your looking for you?

IT Support July 16, 2013

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!

RambanamP
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 16, 2013

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

0 votes
David Anderson September 2, 2014

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.

0 votes
Faisal Ahmad March 5, 2014

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.

MattS
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.
March 5, 2014

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

Faisal Ahmad March 5, 2014

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.

0 votes
IT Support July 16, 2013

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>
Carol Jones September 12, 2016

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.

Suggest an answer

Log in or Sign up to answer