Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Use Scriptrunner cloud to update summary plus a custom field for a group of issues


Hello everyone,


The idea is the following:

I import automatically a list of issues by email for a recruitment Jira board.

On those issues, the summary is something like: "New application: Network Engineer from First_Name Last_Name"

I want to run a script on very first transition (issue created) which transforms this summary:

- removes first 17 chars ("New application:")

- saves job title and populates a custom field with it

- new summary value should be "First_Name Last_Name"


I tried a lot to get the summary value as a string to be able to work on it but whatever I do, I cannot get that value at all.


My code now looks something like this:

// Define a JQL query to search for the issues on which you want to set the impediment flag
def query = "some_query"

// Search for the issues we want to update
def searchReq = get("/rest/api/2/search")
.queryString("jql", query)

// Verify the search completed successfully
assert searchReq.status == 200

// Save the search results as a Map
Map searchResult = searchReq.body

// Iterate through the search results and set the summary and custom field value for each issue returned
searchResult.issues.each { Map issue ->

String sum = (issue.fields.summary as String)

if (sum.toLowerCase().contains('new application:')) {

// Trim and split the summary

sum = sum.substring(17)
String new_summary = sum.split('from ');

//Update the summary and the custom field

def result = put('/rest/api/2/issue/' + issue.key)
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
issue.fields['10102'] : new_summary[0],

summary: new_summary[1]


// Log out the issues updated or which failed to update
if (result.status == 204) {"The ${issue.key} issue was flagged as an Impediment. ")
} else {
logger.warn("Failed to set the summary on the ${issue.key} issue. ${result.status}: ${result.body}")
} // end of loop

return "Script Completed - Check the Logs tab for information on which issues were updated."


I get an error saying that the summary variable is not defined here:
String sum = (issue.fields.summary as String)


Can someone please help me?

1 answer

1 accepted

1 vote
Answer accepted

I managed to fix it today, seems I was missing the fields definition:

def fields = issue.fields as Map


The updated code now looks like this and it works fine:

//Define the JQL query to be run
def query = "project = xx AND key = 'xxxxx' ORDER BY created DESC"

//Execute the query and save the issues as a Map
Map<String, Object> searchResult = get('/rest/api/2/search')
.queryString('jql', query)
.queryString('fields', 'summary')

def issues = (List<Map<String, Object>>) searchResult.issues

//Start the iteration through the issues
issues.each { Map issue ->

//get each issue fields and key
def fields = issue.fields as Map
def issueKey = issue.key

// Get the Custom field to get the option value from
def customField = get("/rest/api/2/field")
.find {
(it as Map).name == 'Job Role'
} as Map

//Get the issue Summary value as string
def sum = fields.summary.toString()

//If condition for issues coming automatically from LinkedIn which were not processed
if (sum.contains("New application: ")) {

//Process the summary information, extract the Job Role and new summary value as First_Name Last_Name
sum = sum.substring(17)
def new_summary = sum.split(' from ');

//Execute the put operation to update the fields
def result = put("/rest/api/2/issue/${issueKey}")
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
fields: [
summary: "${new_summary[1]}",
([value: "${new_summary[0]}"] as Map



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

65 views 0 1
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