Hide Summary Field and Populate During Ticket Creation

The summary field is as far as I can tell impoosible to rename for a specific project. Given that I'm using a workflow that would result in my users being confused as to what they should do with the Summary field I would like to hide it. During creation I would then like to populate it based upon other fields.

How can I do this with JIRA 6? I've seen answers for JIRA 4 which didn't really help at all, the answer provided a javascript solution which I'm not certain where that configuration would go.

Ultimately I'm looking to rename the summary field, but because I can't I'm making an attempt to work around the issue but every idea seems to be met with road blocks.

5 answers

you can use the following simple JavaScript to hide summary field and the other field value to it

<script type="text/javascript">
jQuery(document).ready(function($) {
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
		callSummaryFunction();
	});
	callSummaryFunction();
	
function callSummaryFunction(){
	var issueTypeCreate = $("#issuetype-field").val();
		var issueTypeVal = $("#type-val").text();
		var issuetype=$.trim(issueTypeVal);		
		if((issuetype != null && issuetype === "Bug") || (issueTypeCreate != null && issueTypeCreate === "Bug")){				
			$('#summary').closest('div.field-group').hide();
			var testField=document.getElementById('customfield_13786');
			$(testField).change(function(){		
				$("#summary").val($("#customfield_13786 option:selected").text());					
			});
		}
					
}
});
</script>

Hi Everybody,

We have a working solution for this (at least in JIRA 6.3.12) using Javascript injection and ScriptRunner postfunction you can hide the summary field and populate it with a calculated value:

  1. Add a scriptrunner postfunction in the "create" (after the "Creates the issue originally" step):

    import com.atlassian.jira.issue.Issue
    import com.atlassian.jira.issue.CustomFieldManager
    import com.atlassian.jira.issue.fields.CustomField
    import com.atlassian.jira.user.ApplicationUsers
    import com.atlassian.jira.event.type.EventDispatchOption
    import com.atlassian.jira.component.ComponentAccessor
    CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
    CustomField customField = customFieldManager.getCustomFieldObjectByName("First name");
    String firstName = issue.getCustomFieldValue(customField)!=null?issue.getCustomFieldValue(customField).toString():"";
    customField = customFieldManager.getCustomFieldObjectByName("Last name");
    String lastName = issue.getCustomFieldValue(customField)!=null?issue.getCustomFieldValue(customField).toString():"";
    customField = customFieldManager.getCustomFieldObjectByName("Office");
    String office = issue.getCustomFieldValue(customField)!=null?issue.getCustomFieldValue(customField).toString():"";
    customField = customFieldManager.getCustomFieldObjectByName("Arrival date");
    String arrivalDate = issue.getCustomFieldValue(customField)!=null?issue.getCustomFieldValue(customField).toString():"";
    issue.summary = "Newcomer - "+firstName+" "+lastName+" - "+office+" - "+arrivalDate.substring(0,10)
    def user = ApplicationUsers.toDirectoryUser(ComponentAccessor.jiraAuthenticationContext?.getUser())
    issueManager = ComponentAccessor.getIssueManager()
    issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)


    2. In the Field Configuration add in description of the Summary field the following javascript code:

     

    <div id="summaryNewCommer">
        <script type="text/javascript">
            (function($) {
                AJS.toInit(function() {
                  
                    var currentUrl = window.location.href;
                    if (currentUrl.indexOf('/secure/admin/') == -1) {
                        AJS.$("#summaryNewCommer").parent().parent().hide();
                        jQuery("#create-issue-submit").click(function() {
                            var summary_value = "temp";
                            jQuery("input#summary").val(summary_value);
                        });
                    }
                })
                JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason ) {
                  
                    var currentUrl = window.location.href;
                    if (currentUrl.indexOf('/secure/admin/') == -1 && reason != 'inlineEditStarted') {
                        var $context = AJS.$(context);
                        jQuery("input#summary").val('');
                        $context.find("#summaryNewCommer").parent().parent().hide();
                        jQuery("#create-issue-submit").click(function() {
                            var summary_value = "temp";
                            jQuery("input#summary").val(summary_value);
                        });
                    }
                });
            })(AJS.$);
        </script>
    </div>

 

 

The JavaScript would go in the description of the field in a field configuration of the project. Probably the best way to do it. You can achieve similar results with the Behavior Plugin also but again requires a bit scripting.

You can create a customField and "Inject" JavaScript there (Not nice, but works). Simple name it "NoSummaryField" and paste your JS in the customField description. Now you can add it to your createIssue Mask.

</div>
<script type="text/javascript">
  jQuery("label:contains('NoSummaryField')").parent().hide();
  jQuery("input#summary").parent().hide();

  jQuery("#create-issue-submit").click(function(){
    
    // TODO: fetch ur summary value here
    var summary_value = "TEST";

    jQuery("input#summary").val(summary_value);
    
  });
</script>
<div>

Worked for me on JIRA 6.0.2

In JIRA 6.3.7, JavaScript doesn't appear to work within field descriptions. It gets converted to text (html entities).

Francois SERGOT that worked like a treat for me on JIRA v6.4.1.  Only thing I had to do to get the scriptrunner postfunction script to compile was to ensure the following statement was changed from:

issue.summary = "Newcomer - "+firstName+" "+lastName+" - "+office+" - "+arrivalDate.substring(0,10)

to

def issue.summary = "Newcomer - "+firstName+" "+lastName+" - "+office+" - "+arrivalDate.substring(0,10)

I had to insert a 'def" keyword in front of the statement and all was good after that.

In much appreciation,

Trevor 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,816 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot