Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Building text in "Summary" based on custom fields

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

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

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.

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
Community showcase
Published in Jira Service Management

Why upgrade to Jira Service Management Premium?

We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan.  &nb...

170 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you