How can I set summary value using Javascript?

Lucas Boczkowski January 6, 2013

Hello.

I want to show by default the value "Paso N° " in sumamry field, when an user create an issue.

I tried with that:

<script type="text/javascript">
if (document.getElementById("summary").value == "") {
document.getElementById("summary").value = "Paso N° ";
}
</script>

The problem is that when I mark the "Create Another" Checkbox, then in the second issue that I want to create, the field summary appears null... maybe I have to change my code. But I don't know how.

Thanks.

4 answers

1 accepted

2 votes
Answer accepted
Nitram
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.
January 7, 2013

Hi,

Try this,

<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
summaryToBeCopied();
});
summaryToBeCopied();

function summaryToBeCopied(){
$('#summary').val('New Val');
}

});
</script>

Hope this Helps.

Nitram
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.
January 7, 2013

Add the above in the field description.

Raye Raskin
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.
April 29, 2013

The problem with Nitram's script is it is applied to all Issue Types. Can someone please modify this javascript to only apply to, say, Issue Type "Task"?

I'm using Jira 5.2.11.

Thank you.

Enid Gjoleka September 30, 2013

Hi Nitram,

Thanks for your code, it works perfectly.

saravanan subramanian February 6, 2014

Raye raskin - what you can do is - you can create a seperate field configuration for the issue type task - and then update the summary description under that so that it runs for Task issue type alone.

0 votes
artafon October 14, 2013

Hi!

I'm adding code in desription field Summary in configuration field on project(not default configuration), but it does not work for

0 votes
artafon January 23, 2013

Hello!

Could you help me also with writing javascript about change field "summary" when user create issue. Your script above pretty good works, but i have another problem. So, I change summary for type issue "contact". User can make another issue type, for example, "contract". If the last created issue type "contract", then user on the create screen screen change project and issue type (contact) and field "summary" is null. How can i fixed this?

I hope for your help! 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.
September 30, 2013
0 votes
Renjith Pillai
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.
January 7, 2013

Don't mind me saying this, isn't summary supposed to be unique. Out of curiosity, why are you creating issues with same summary?

JamieA
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.
January 7, 2013

He's just trying to set a default value... eg "Step no: " - and the user appends 99 or something.

Lucas Boczkowski January 7, 2013

Exactly, I want to show a default value, and then the users are going to change it (Paso N° 1, Paso N° 2, etc.).

Nitram, your code works perfectly.

Thanks!

Suggest an answer

Log in or Sign up to answer