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,551,860
Community Members
 
Community Events
184
Community Groups

Possible to automatically create stories when an epic is created (ScriptRunner)

Hello All,

I'd like to know if it is possible through ScriptRunner or another addon to easily set some rules to create stores. Something like this:

Let's say on Epic, there is a custom field with A, B, and C

If Epic is created and custom field = A, create story 1, 2, and 3

If Epic is created and custom field = B, create story 4

If Epic is created and custom field = C, create story 5

 

If this is possible, does anyone have an example I could reference?

2 answers

0 votes
Orkun Gedik
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.
Sep 13, 2018 • edited

Hello Wes,

I think the following  postfunction script will be helpful for you. Do not forget the place the postfunction to move under the issue created event.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import org.apache.log4j.Logger

Logger log = Logger.getLogger("Your script name")
log.debug ("Script started")

try {
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issue = issue

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("your custom field id")
def customFieldValue = customField.getValue(issue)

switch (customFieldValue){
case "A":
createStory(user, issue, ...); // story1
createStory(user, issue ,...); // story2
createStory(user, issue, ...); // story3
break
case "B":
createStory(user, issue, ...); // story4
break
case "C":
createStory(user, issue, ...); // story5
break
default:
log.error("Invalid input!")
break
}
}catch(Exception e){
log.error(e)
}

private void createStory(user, issue, ...){
MutableIssue newStory = ComponentAccessor.getIssueFactory().getIssue()
newStory.setSummary(...)
newStory.setReporter(...)
newStory.setAssignee(...)
newStory.setParentObject(...)
newStory.setProjectObject(...)
newStory.setIssueTypeId(...)

def inputParameters = ["issue": newStory] as Map<String, Object>
ComponentAccessor.getIssueManager().createIssueObject(user, inputParameters)
ComponentAccessor.getSubTaskManager().createSubTaskIssueLink(issue, newStory, user)
}
0 votes
Milan Chheda [INFOSYSTA]
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.
Sep 10, 2018

You can use Create on transition add-on. Once this add-on installed, you can go to workflow, and add a post-function which will show you below options:

 

createIssueOnTransition.PNG

You can create issues based on the conditions. Hope this helps.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events