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:
I found a solution, maybe it will be useful to someone.
Long JobFieldId = 11111LLong 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))}
else{issue.setSummary(MyIssue);}
It looks like you're new here. Sign in or register to get started.