How to create multiple stories without post-script function

Adrian Ma March 29, 2019

Hello,

 

My Objective: To be able to create multiple Stories with a click of a button (usable by non-technical people) or script.

Requirements:

- The approach should be usable by non-technical people.

- This approach should be re-usable.

- I don't want to modify the existing "Create Story" workflow because we would still need that default behaviour.

 

Background Context:

We do Agile, and as the Project Manager / Scrum Master, we need to create the same set of stories for every requirement.

E.g. For each Requirement, we need to create:

- Story to implement Requirement logic

- Story for implement Requirement copy / strings

- Story to implement Accessibility

I want a script / button that creates all three stories into my backlog in one-click!

 

We are open to any add-on / plug-in solutions.

 

Any help is appreciated. Thank you in advance.

2 answers

1 accepted

0 votes
Answer accepted
Adrian Ma March 31, 2019

Hi Everyone,

I developed my own workaround from suggestions around the community in case anyone in the future is interested.

 

My Solution

Objective: In my Agile Board, if I select to create an Issue with type "Cross", it will generate 4 Story issues from the details from the original. 

Notes:

- The issue type "Cross"is arbitrary, I just needed to associate my workflow with any un-used issue type in my project that IS NOT Story. If you mistakenly associate it with Story, you will create an infinite loop.

- I generated 4 Story issues because this applies to my specific project, you can customize it however you like.

 

My Implementation

Note: I'm using the ScriptRunner plug-in

Steps

1. I created a new workflow, Create Multiple Issues Workflow

2. Edit the Post Functions within the "Create" Transition (easiest way is go to Diagram view and it's the first line. Under Options, click on Post Functions).

- Change the first Status in your workflow should be "To Do" instead of "Open". Therefore, your Create transition should go to "To Do". This aligns it with a default Story issue flow.

3. Add post function - Clones an issue, and links

- Clone all fields

- Set Target Issue Type to Story

- Ensure this post function is after 1. Creates the issue originally.

4. Redo step 3 for however many Story issues you want created. I had 3 + 1 (the original) which in total is 4.

5. Add post function - Custom script post function

- In here, I developed a script to convert/move the original issue to be of Issue Type - Story.

- Ensure this is before Re-index an issue to keep indexes in sync with the database.'' ordering

Here's the code

import org.apache.log4j.Category
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.issuetype.IssueType
import com.atlassian.jira.event.type.EventDispatchOption


/* Define a Logger */
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)

def constantsManager = ComponentAccessor.getConstantsManager()

Issue issue = issue // This what I was looking for :-). As simple as it is, but I didn't know that.

IssueType targetIssueType = null

log.debug "IssueType old = " + issue.issueType.name

def collection = constantsManager.getAllIssueTypeObjects()
def iterator = collection.iterator()
while(iterator.hasNext()){
def issueType = iterator.next()
if(issueType.name == "Story"){
targetIssueType = issueType
}
}

log.debug targetIssueType.name
issue.setIssueTypeObject(targetIssueType)
log.debug "IssueType new = " + issue.issueType.name

IssueManager issueManager = ComponentAccessor.getIssueManager();
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()


// issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, true);
issueManager.updateIssue(user,issue,EventDispatchOption.ISSUE_UPDATED, false);
log.debug "end of script"

 Now we're done with our workflow.

6. Associate the workflow with a workflow scheme.

- Find your project's workflow scheme and Edit.

- Select Add Workflow and associate your custom workflow with an issue type. In my case, I chose an arbitrary un-used issue type, Cross.

- Ensure your Project supports the new issue type.

 

Voila! Done.

Go to your Agile board as per usual, and try creating a new issue "Cross". Once, you do, it will generate multiple stories for you.

 

Hope this helps.

0 votes
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 30, 2019

Hi Adrian,

there are multiple apps that can provide a solution to your requirement. Some are dedicated to creating multiple issues from templates, some are more multi-purpose but can also provide a good solution.

One such example is our JMWE app, which is available for both Jira Server and Jira Cloud (you didn't specify which you are using) and offers a "Create Issue(s)" post-function that can automatically create multiple issues during a transition.

I'm sure others will be able to suggest other apps.

Adrian Ma March 31, 2019

Thanks for the suggestion

Shahzaib Muhammad akram
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2025
  • The small flakes create a soft, cushioned surface, ideal for your horse’s rest and comfort.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events