Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Remove part of text from summary field

AJ I'm New Here Aug 26, 2022

Hi, I've been doing jira for a while, but only recently started using scriptrunner. I created a script that adds the value of another single select custom field (city) to description. The problem is that I need a transition that allows me to change city, and I don't know how to remove the previous entry from the description. If I use my previous postfunction it adds another city to description:

example tittle # cityA
example tittle # cityA # cityB
Is anyone able to guide me with some solution?

1 answer

1 accepted

2 votes
Answer accepted

I found a solution, maybe it will be useful to someone.

Long JobFieldId = 11111L
Long CityFieldId = 11112L

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField JobField = customFieldManager.getCustomFieldObject(JobFieldId)
CustomField CityField = customFieldManager.getCustomFieldObject(CityFieldId)

IssueManager issueManager = ComponentAccessor.getIssueManager()
String JobValue = issue.getCustomFieldValue(JobField)

String MyIssue = issue.getSummary().toString()
int hash = MyIssue.indexOf(" # ");
if(hash > 0)

MyIssue = MyIssue.substring(0,hash)

if (JobValue!=null && (JobValue == ("Things to do")))
issue.setSummary(MyIssue + " # " + issue.getCustomFieldValue(CityField))



Suggest an answer

Log in or Sign up to answer

Atlassian Community Events