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

Your Points Tracker
Challenges
Leaderboard
  • 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
Recognition
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?
Kudos
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

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

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.

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)
}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

99 views 0 6
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