Script to replace Summary Field

Deleted user August 12, 2013

I would like to know if there is a script so that I can replace the Summary field with two custom fields that the user fills in.

Scenario; user fills in the Issue Create form, and two of the custom fields (CF1 and CF2) now have data in them.

I would then like the script to run as a post function which then updates the Summary field with "CF1 relies on CF2" (for example)


Is this possible?

5 answers

1 accepted

0 votes
Answer accepted
Nadir MEZIANI
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.
August 12, 2013

Hi,

You can do it with javascript or with JJUPIN.

Deleted user August 12, 2013

I thought you might be able to, but I have no scripting knowledge, so I was hoping someone would be able to help me write the script.

Nadir MEZIANI
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.
August 12, 2013

Hi,

In the configuration customfield issue type scheme, put this script in the description summary field to hide it (summary field )

<script type="text/javascript">

var summuryField=AJS.$("#summary").parent();

summuryField.hide();

</script>

And in the configuration customfield issue type scheme, put this script in the description of one of your custom field

For example ids of your custom fields are like this

CF1 id = customfield_xxxxx
CF2 id = customfield_yyyyy

We put this script in the description of CF2

<script type="text/javascript">

AJS.$('#customfield_xxxxx').keypress(function(){AJS.$('#summary').val(AJS.$("#customfield_xxxxx").val() + AJS.$("customfield_yyyyy ").val());})

</script>

Deleted user August 12, 2013

This didn't work because the Summary field is set to Required, and I can't seem to un-required it.

Nadir MEZIANI
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.
August 12, 2013

Hi,

Set summary field value with a default value.

Add this script to summary descriptinon

<script type="text/javascript">
 
var summuryField=AJS.$("#summary").parent();
 AJS.$("#summary").val("default value");
summuryField.hide();
 
</script>

and you can use keyup

Deleted user August 13, 2013

Ok, so the issue is now being raised, but the value of summary is coming through as "default value"

the CF ID's are:

CF1: 11327
CF2: 11320

The description of CF2 is:

<script type="text/javascript">
AJS.$('#customfield_11327').keypress(function(){AJS.$('#summary').val(AJS.$("#customfield_11327").val() + AJS.$("customfield_11320").val());})
</script>

Deleted user September 24, 2013

Sorry for the late reply on this!

I've tried that but the same thing is happening.

CF_11327 - Radio Button called Status with two values (Active and Disabled)
CF_11320 - Text Field (< 255 characters) called Name

0 votes
Benjamin Kramer February 8, 2015

Works very Good. 

<script type="text/javascript">

AJS.$('#customfield_10009').keyup(

function(){AJS.$('#summary').val(AJS.$("#customfield_10101").val()+AJS.$("#customfield_10107").val()

);})

</script>

 

Result is: XXXXYYYYY

 

How do I get the Result: XXXX_YYYYY_Name of the Reporter ?


Thanks

0 votes
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.
September 24, 2013

you can try something like this

&lt;script type="text/javascript"&gt;
jQuery(document).ready(function($) {	
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {	
	addSummary();
});
addSummary();
function  addSummary(){		
		$('input:radio[name=customfield_11327]').click(function() {	
			AJS.$('#summary').val($('input[name=customfield_11327]:checked + label').text() + AJS.$('#customfield_11320').val());
		});	
		
	AJS.$('#customfield_11320').keyup(function(){
		AJS.$('#summary').val($('input[name=customfield_11327]:checked + label').text() + AJS.$('#customfield_11320').val());
		});

}
	
});
&lt;/script&gt;

i suggest load javascript as webresource module in a plugin

0 votes
Bharadwaj Jannu
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.
September 18, 2013

hi Ashley Powell,

you write a postfunction such that get the customfield values CF1 and CF2 from issue object.

Based on your requirement of customfield values set summary using the same issue object.

Finallu update issue and re-index.

You can check for workflow module postfunction.

Deleted user September 24, 2013
How do you get round the fact that the Summary field is on the screen and a required field?
I'd prefer if it wasn't visible to users, and didn't need them to interact with at all.
Also, do you have any idea what this postscript would look like?
Bharadwaj Jannu
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.
September 24, 2013

by default, summary field is required and go through the link

Also, the postfunction will be something like this:

import com.atlassian.jira.component.ComponentAccessor;

import com.atlassian.jira.issue.MutableIssue;

import com.atlassian.jira.issue.IssueManager;

import com.atlassian.jira.security.JiraAuthenticationContext;

MutableIssue issue=(MutableIssue)transientVariables.get("issue");

Object CF1 = issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("Cus1"));

Object CF2 = issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("Cus2"));

//some logic

if(CF1.toString().equals("x") && CF2.toString().equals("y")){

issue.setSummary("xy"+issue.getSummary());

}

try

{

IssueManager issueManager=ComponentAccessor.getIssueManager();

JiraAuthenticationContext authContext=ComponentAccessor.getJiraAuthenticationContext();

issueManager.updateIssue(authContext.getLoggedInUser(),issue,EventDispatchOption.ISSUE_UPDATED,true);

}

catch(Exception e){

e.printStackTrace();

}

0 votes
Błażej O_
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.
August 13, 2013

Yes, you can do it easily.

We do it using Kepler Rominfo's SIL custom field.

1) Get Kepler customfields from https://marketplace.atlassian.com/plugins/com.keplerrominfo.jira.plugins.keplercf

2) Create new SIL Script Custom Field for example mySILsummary

3) Enter configuration of the field

4) Click "Edit SIL Script"

5) Enter following code:

return customfield_11327 + " relies on " + customfield_11320;

6) In the post-function after issue creation just copy value from the mySILsummary to summary.

Voila.

We do it all the time with our issues, and it works like a charm :) SIL script field is really helpful every time you need a summary standarized in some way.

Deleted user September 24, 2013

How do you get round the fact that the Summary field is on the screen and a required field?


I'd prefer if it wasn't visible to users, and didn't need them to interact with at all.

Błażej O_
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.
September 24, 2013

Yes, it is quite uncomfortable to must have the summary field on the creation screen. However, you can pre-fill it using Behaviours plugin.

In the administrative panel -> plugins -> Behaviours, add new mapping. Map to project and/or issue type you want. Than click "fields", select Summary field, and Add serverside script.

You can use similar one:

import com.atlassian.jira.issue.IssueFieldConstants
import java.util.List
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager

User user = ComponentManager.getInstance().getJiraAuthenticationContext().getUser()
FormField formSummary = getFieldById("summary")
FormField formType = getFieldById("issuetype")

if (formType.getValue().contains("paste here number id of issue type"))
{formSummary.setFormValue("Your summary text")
}
else
{formSummary.setFormValue("")
}

This script will prefill summary only when you choose the required issue Type.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events