Can I set a default value for SUMMARY field, on a per request type basis?

inspirednz July 27, 2020

I would like to set a default SUMMARY value for certain request types.

I found info here, stating to insert this javascript into the field. The instructions are:

 

  1. Go to the respective Field Configuration of the project.
  2. Find for the Summary field.
  3. Click on Edit.
  4. Input the following JavaScript at the Description of the field:

<script type="text/javascript">
if (document.getElementById("summary").value == "") {
document.getElementById("summary").value = "<Default Value for Summary>\n";}
</script>

But I gather this will affect this field in all forms, etc. Is that correct?

I read elsewhere that I could add,

if (issue.get("issuetype").name == "Issue Type" {

But actually even without this additional code, the above JS doesn't have any affect on the new issue form (on the user portal). And on the Agent site of things, I shows the JS under the field, as its description.

Is there any way (without using paid plugins/add-ons to achieve this?

 

2 answers

0 votes
Sam Bartolome
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.
May 26, 2021

Hi,

For the customer portal you can set a default value and hide it too.

Regarding your main enquiry, make sure the Enable HTML in field descriptions and list item values is on in your instance (at least for Server/DC) and then it will populate.

I would also suggest to add an && clause to your example

 

<script type="text/javascript">
if (document.getElementById("summary").value == "") && (issue.getAsString("issuetype").name == "Issue Type") {
document.getElementById("summary").value = "<default Value for Summary>\n";}
</script>

 

 

You may need to play a bit  with the code, sorry I'm pretty bad at coding

0 votes
Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 30, 2020

Hello @inspirednz

Thank you for reaching out.

I see that you are currently subscribed to Jira Cloud. Is that correct? Or are you using Jira Server (self-hosted)?

I ask this question because the functions/customizations you found using Javascript are applicable to Jira Server, however, they can not be implemented in Jira Cloud because Javascript and HTML create an XSS vulnerability and, for that reason, they are not allowed in Jira Cloud. You can find more details in the following documentation:

Functional differences in Jira Cloud products 

That being said, the best way to set a default text for the summary field based in the request type selected in Jira Cloud would be by using Jira Automation. These would be the steps:

  1. Navigate to your Service desk project > Project settings > Project automation (Not automation)
  2. Create a new automation rule to set the summary field with a pre-determined text, using conditions to define the text based on the request type selected:
    Screen Shot 2020-07-30 at 17.12.56.png

Let us know if you have any questions.

Matt_ P January 18, 2021

@Petter Gonçalves I've tried your instructions for Jira Cloud and does doesn't seem to resolve what I was hoping to accomplish. When I go to create a new issue it still has a blank required field in the standard Create issue dialogue and clicking create without anything input into the summary results in the "You must specify a summary of the issue." so the Automation never runs.

My hope was to default this create issue Summary to "[Auto]" and if the user overrides it will use the new name otherwise my automation post create would replace the name with fields provided at the time of creation by the user to format a default summary. Ideally, for this type of issue I'm designing, 99% of the time I don't want the user to have to think about entering anything in the to required Summary field.

The automation 'When: Issue Created' seems to only trigger post creation dialogue. 

2021-01-18 09_11_14-Project automation - Jira.png
It is also unclear as your steps refer to "Project automation (Not automation)", I only see Automation under the Project settings. I do not see anything that might indicate a difference between Project Automation and Automation.
 2021-01-18 09_21_51-Project automation - Jira.png

Am I missing something or is there another way to achieve my goal?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events