Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Whenever a ticket is created , need to add Epic Link automatically

Preeti Yadav April 16, 2024

Hi Team,

I have issue type "A" and whenever this type of issue is created , Epic Link should be automatically added to it .

 

Please suggest some script .

 

Thank You!

2 answers

1 vote
John Funk
Community Champion
April 16, 2024

Hi Preeti,

Are you saying create an Epic every time an issue is created with a certain issue type? Or link it to an existing Epic? And if an existing Epic, then how will it know which one? 

Preeti Yadav April 16, 2024

Hi John,

Yes the existing one , we have as Epic which is already there , just whenever is issue type "Snow-Bug" is getting created it should be linked to the epic.

 

I have written some script - But It is not working when "Snow-Bug" is created automatically through mail handler.

 

It is getting linked to epic only when created manually.

Below is the script- 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def issueKeyToAssociate = "GOXFUNC-8734" // Epic Key to associate with

def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager

def issue = event.issue as Issue // Assuming 'event' is provided by Jira Listener

// Get the predefined epic issue
def epicIssue = issueManager.getIssueByCurrentKey(issueKeyToAssociate)

if (epicIssue) {
// Get the Epic Link custom field
def epicLinkField = customFieldManager.getCustomFieldObjects(issue).find { it.name == 'Epic Link' }

if (epicLinkField) {
// Check if the issue being created is of the desired issue type
if (issue.issueType.name == "SNOW-Bug") { // Replace "SNOW-Bug" with your actual issue type
// Update the Epic Link custom field
epicLinkField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(epicLinkField), epicIssue), new DefaultIssueChangeHolder())
}
} else {
log.error("Epic Link custom field not found.")
}
} else {
log.error("Epic issue $issueKeyToAssociate not found.")
}

 

John Funk
Community Champion
April 16, 2024

You don't need all of that. Just create an automation rule that is based on an Issue Created trigger.

Then add a Condition for Issue Type = Snow-bug

Then add an action for Edit Issue. Select the Parent field

Put in the value GOXFUNC-8734

Update the issue and you are good to go. 

Preeti Yadav April 16, 2024

Hi John,

We don't have Automation plugin hence we can not use this.

Is there any other way?

 

Thank You!

John Funk
Community Champion
April 16, 2024

Oh, are you in Server or Data Center? Also, there should be a free Lite version of Automation for Jira that you could use. 

Do you have ScriptRunner or some other plugin for workflows? 

Preeti Yadav April 16, 2024

Hi John,

Yes we have script runner plugin.

 

John Funk
Community Champion
April 16, 2024

I guess that is what you were trying to do with above.  :-)   That's outside of my expertise, but you definitely should be able to accomplish it with the tool. 

0 votes
Nikola Perisic
Community Champion
April 16, 2024

Hello @Preeti Yadav 

You can use the automation rule for this. Screenshot 2024-04-16 at 11.35.27.png

Here is the example. For the Summary field, you can change this to be the one suiting your needs. More documentation on the smart values can be found here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/

Preeti Yadav April 16, 2024

Hi Perisic,

We don't have Automation plugin hence we can not use this.

 

Thank You!

Suggest an answer

Log in or Sign up to answer