Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Default epic to newly created tickets , but unable to assign different EPIC while creating new one

Hi Team,

I have a request to add every "Task" issue assign to one specific epic link. I have used below code and working excepted, but currently when creating a new task, even if we assigned a different epic to a task, at the time of creation it automatically changes it and assigns mentioned epic the script (EPIC-1). we only want EPIC-1 assigned when the field it left blank during the ticket creation. Could you please suggest on this.

The original request of this requirement is :


Link :

import com.atlassian.jira.component.ComponentAccessor

// When you create an issue of issue type Story that will be under an Epic
final issueTypeName = "Story"

// The issue key of the Epic
final epicIssueKey = "EPIC-1"

if ( != issueTypeName) {

def epicLinkCustomField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).findByName("Epic Link")
def newEpic = ComponentAccessor.issueManager.getIssueByCurrentKey(epicIssueKey)

issue.setCustomFieldValue(epicLinkCustomField, newEpic)

1 answer

Hi @Lakshmi S

You will need to modify the script slightly to suit your requirements.

In your code, I have observed, there is no condition to check if the Epic Link field is empty or not.

You should include something like:-

def epicLinkCustomField = customFieldManager.getCustomFieldObjects(issue).findByName("Epic Link")

(epicLinkCustomField.getValue(issue).toString() == "null") {

to ensure that the Epic Link field will be auto-filled only if it is empty.

Also, it would help if you used the Issue Manager to update the Issue as shown below:-

issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.ISSUE_UPDATED, false)

to ensure that the change to the Epic Link field is updated.

Below is a fully working example script for your reference:-

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

def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser

final issueTypeName = "Task"
def epicIssueKey = "ET-1"

def epic = issueManager.getIssueByCurrentKey(epicIssueKey)
def epicLinkCustomField = customFieldManager.getCustomFieldObjects(issue).findByName("Epic Link")

if ( != issueTypeName) {

if(epicLinkCustomField.getValue(issue).toString() == "null") {
issue.setCustomFieldValue(epicLinkCustomField, epic)
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.ISSUE_UPDATED, false)

Please note this example code is not 100% exact to your environment. Hence, you will need to make the required modifications.


I hope this helps to solve your question :)


Thank you and Kind Regards,


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...

227 views 14 14
Read article

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