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,646,752
Community Members
 
Community Events
196
Community Groups

How to get the current issue after the issue is create?

Edited

Hi, I am using groovy script in post function to update the value of custom field after the issue creation transition. But I don't know how to get the created issue.

I know how to get the issue by its ID but I have to create script for every Issue created and I dont know how to do that.

 

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 09, 2018

There is an internal variable called issue. That is why you can just write

issue.getKey()

it will return the key of the created issue.

I have the following code in a post function on create transition

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.util.UserManager 
import com.atlassian.jira.event.type.EventDispatchOption

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def multiGroupCf = customFieldManager.getCustomFieldObjectByName("Demo-Π.Σ.Κ.Ε. Assignable Groups") //multigroup picker custom field

def group1 = groupManager.getGroup("EYKE Group") //jira group
def group2 = groupManager.getGroup("Group_Epilogi_Proistamenon") //jira group
def group3 = groupManager.getGroup("ISO - Security Officers") //jira group

def groupList = [group1, group2, group3]

issue.setDescription("lalal")
issue.setCustomFieldValue(multiGroupCf, groupList)

The use of issue keyword does not work and when I create a new issue I'm getting the following message:

"We can't create this issue for you right now, it could be due to unsupported content you've entered into one or more of the issue fields. If this situation persists, contact your administrator as they'll be able to access more specific information in the log file."

 

So, it seems that issue variable cannot be used to get the current issue.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events