Autofill and hide summary with custom fields in Jira Server

In Jira Software Server the “Summary” field is always mandatory. Sometimes it does not make sense to let the user fill in the summary field manually. In expample if you have created a workflow for a special type of request. There you always want to have the same structured information visible in the summary. This could help the team who takes care about the request. In this case all necessary information is already filled in custom fields. Now you could be a good idea to autofill and hide summary with information from this fields.

There are different ways of achieving this – the easiest is to do it by JavaScript. For this approach you don’t need any Add-On and only have to customize the “Field Configuration”:

  1. Go to “Project Settings” and customize your “Field Configuration”
  2. Search for the “Summary” field and click onto “Edit”
  3. You are now able to add a description for the summary field. Into here you can add a piece of JavaScript code that hides the field and automatically fills in a value:

Simply copy one custom fields value and autofill and hide summary field

<script type="text/javascript">
AJS.$('#summary').parent().hide()

AJS.$('#customfield_14494').change(function(){
var value = AJS.$(this).val()
AJS.$('#summary').val(value)
})
</script>

The above piece of code first hides the summary. Then it takes the value from “customfield_14494” when it is changed and writes it into the Summary field.

Combine multiple custom fields values and populate to summary

<script type="text/javascript">
AJS.$('#summary').parent().hide()

var fillSummary = function(){
var value1 = AJS.$('#customfield_14494').val()
var value2 = AJS.$('#customfield_12216').val()
AJS.$('#summary').val(value1 + " " + value2)
}

AJS.$('#customfield_14494').change(fillSummary)
AJS.$('#customfield_12216').change(fillSummary)
</script>

The above piece of code again first hides the summary field. When one of the custom fields change it takes the values of customfield_14494 and customfield_12216 and writes them combined into the summary field.

It would also be possible to update the summary with a Postfunction by using Adaptavist Scriptrunner or JMWE Add-On. But also by using these Add-Ons you would have to hide the summary. Adaptavist Scriptrunner would offer Behaviours to do this.

See this code in GitHub

Leave a Reply