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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,560,301
Community Members
 
Community Events
185
Community Groups

Updating Summary via Groovy Script doesn't work

I need to slightly change the summary on a lot of issues. So I created a workflow with an action to do this and I created the following postfunction script:

 

import com.atlassian.jira.issue.IssueManager

import com.atlassian.jira.issue.MutableIssue

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.user.ApplicationUser

import com.atlassian.jira.event.type.EventDispatchOption

IssueManager im = ComponentAccessor.getIssueManager()

MutableIssue currentIssue = im.getIssueObject(issue.key) as MutableIssue

ApplicationUser loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

String summary = issue.getSummary()

String newSummary = ""

log.warn("Summary: "+summary)

if (summary.endsWith("(Alfa)")) {

newSummary = summary.replaceAll("\\(Alfa\\)","(XX)")

log.warn("New summary: "+newSummary)

currentIssue.setSummary(newSummary)

def changedIssue = im.updateIssue(loggedInUser, currentIssue, EventDispatchOption.ISSUE_UPDATED, false)

log.warn("Updated: "+changedIssue.key)

} else {

log.warn("Nothing to do")

}
The jira issue does NOT change summary. But in the issues history it is stated as if it did!?
I can't figure this out.
Any help would be much appreciated.

2 answers

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 31, 2023

If you're using a recent version of Scriptrunner to run the scripts, you can use HAPI to simplify the script:

 

def issue = Issues.getByKey('SR-1') as MutableIssue

issue.set {
setPriority('Highest')
setSummary('my new summary')
}

issue.store()

I'm using 7.6.0 and it doesn't like 

Issues.getByKey
0 votes
Kristján Geir Mathiesen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 30, 2023

Hi @Michael Madsen and to do some expectation management: I will am not a coder and probably won't solve your problem :)

Have you tried asking chatPBT?

@Rodney Nissen had an interesting article yesterday about that. Check it out and let us know how it went. Of course try the code out in a test environment and all that.

HTH,
KGM

ChatGPT is clueless

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 31, 2023

Yep, I've seen it asked around 400 Jira questions, including 50 that were coding, it only gave one that wasn't subtly or horribly wrong, and in the code, invented APIs and calls that simply don't exist.

It's not a bad idea, I'd use it, but only after it's been trained on a subject with a decent dataset (and that means "not Stackoverflow" for a lot of subjects, as there's a lot of really bad answers there).   It certainly has not been trained on Atlassian stuff yet. 

But there are people working on it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events