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

Update summary field using Groovy

Mike Whitlock Dec 10, 2013

I am just trying a take the value from a custom field and add it to the current summary. I am using the code below in script runner and in the result I get the new summary that I want, but the issue summary does not actually update. Please help

ComponentManager componentManager = ComponentManager.getInstance()

IssueManager issueManager = componentManager.getIssueManager()

CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()

def issue = componentManager.getIssueManager().getIssueObject("PR047EXE-74")

// gets the value from a custom field which is 123

def QCNum = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'QC Defect ID'};

def QCNumValue = issue.getCustomFieldValue(QCNum);

//add the 123 and a : before the current summary

def newSummary = QCNumValue + ": " + issue.summary;

issue.summary = newSummary;

//in script runner the result is "123: summary" which is exactly what I want the summary to update to but it never updates... it just stays "summary" --- please help

1 answer

1 accepted

0 votes
Answer accepted

Maybe this will work for you

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
 
void setSummary(String key,String newSummary) {
IssueManager im = ComponentAccessor.getIssueManager();
        MutableIssue issue = im.getIssueObject(key);
        issue.setSummary(newSummary);
        issue.store();
}
 
setSummary("CD-4","Insert your Summary");

David Willson May 14, 2019

Doesn't work

 issue.store();

is deprecated.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Jira Software

Demo Den Ep. 5: Meet Jira Mobile

See how to use Jira on the go! Demo Den Episode 5 is here: meet Jira Mobile with  Jira  Product Manager Rayen Magpantay.  Demo Den is in our monthly series where a Jira PM demonstrates...

306 views 1 10
Join discussion

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