Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Building text in "Summary" based on custom fields

Malene Lunde Einarsen December 7, 2020

Hi,

I'm trying to use Script Post-Function [ScriptRunner] to create the summary of an issue based on the customers' answers in other custom fields.

Jira claims the script has no errors, and that all the issues I submit are passing this script. I am unable to see any logs which show why this is not working, however.

Mind you, I am very new to this scripting-business.

Why is this seemingly running fine - but not updating the "Summary" (nor giving me any log.info I write)?

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.worklog.WorklogImpl
import com.atlassian.jira.event.type.EventDispatchOption

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def cfKommune = customFieldManager.getCustomFieldObject(12009)
def cfGnr = customFieldManager.getCustomFieldObject(12200)
def cfBnr = customFieldManager.getCustomFieldObject(12201)
def cfAdresse = customFieldManager.getCustomFieldObject(12202)
def cfKortBeskrivelse = customFieldManager.getCustomFieldObject(12209)

if (issue.getIssueType() == "Ny tilknytning/forsterkning") {

String kommune = issue.getCustomFieldValue(cfKommune)
String gnr = issue.getCustomFieldValue(cfGnr)
String bnr = issue.getCustomFieldValue(cfBnr)
String adresse = issue.getCustomFieldValue(cfAdresse)
String kortBeskrivelse = issue.getCustomFieldValue(cfKortBeskrivelse)

def newSummary = kommune + " - " + gnr + "/" + bnr + " - " + adresse + " - " + kortBeskrivelse

issue.setSummary(newSummary)

log.info(newSummary)

}

2 answers

1 accepted

0 votes
Answer accepted
Malene Lunde Einarsen December 9, 2020

I decided to use Automation for Jira instead, as it proved to be MUCH easier (and I had forgotten about the use of smart values there, as it's not always clearly mentioned). 

It's working as expected now - and the script above is in the bin. 

0 votes
Nic Brough -Adaptavist-
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.
December 7, 2020

Where is this script being run?

As an aside, I would not recommend doing this.  You're destroying data that the customer took time to enter, that's rather annoying for them.  Also, the summary may not be big enough to hold everything (I can't tell from the scripts if your data might be too long).  I'd recommend using a separate custom field if you really need this string built.

Malene Lunde Einarsen December 9, 2020

Hi, this was being run in the workflow from Create to the first status. 

I decided to use Automation for Jira instead, as it proved to be MUCH easier (and I had forgotten about the use of smart values there, as it's not always clearly mentioned). 

It's working as expected now - and the script above is in the bin. 

 

To explain the usage: the summary field was never really used for this customer request type, as the data my company needed is their county, address, and "lot ID" numbers. The customer enters these details in various custom fields, and it is still available in the custom fields after, but is also combined into the summary upon submission. This way my company gets an overview over work being done in/at various counties/addresses without digging through or displaying various custom fields. It makes each issue very easily recognisable. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events