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,556,699
Community Members
 
Community Events
184
Community Groups

what is the error in below grovvy script for post funtion

While moving to in progress, sub-tasks would be created for each application selected in Application Name (multiselect)
Summary: <App_Name> - Subtask
Select List 1 : Value from parent task
Text 1: Value from parent task
Number 1: Value from parent task"

 

 

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue

def parentIssue = sourceIssue
int numMarkups

doAfterCreate = {

if (parentIssue.getIssueType().getName() != 'Task')
{return}

if (parentIssue.summary.contains("Markup Master Task"))
{
numMarkups = Integer.parseInt(parentIssue.summary);
}

if (numMarkups >= 50)
{
return
}
else
{
def i = 0
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()

for (i; i < numMarkups; i++)
{
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setSummary("Markup" + i.toString())
newSubTask.assignee == parentIssue.assignee
newSubTask.components == parentIssue.getComponents()
newSubTask.setParentObject(parentIssue)

newSubTask.setPriorityId(constantManager.getPriorities().find {
it.getName() == "P2" }.id)

newSubTask.setProjectObject(parentIssue.getProjectObject())

newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
it.getName() == "Sub-task" }.id) }

}


}
}

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

Welcome to the Atlassian Community!

Your 

def parentIssue = sourceIssue

is making a nonsense of the script - sourceIssue is not a variable you have any access to in a post-function.

Try removing that line completely, and just using "issue" instead of "parentIssue" when you need to look at the current issue.

Your code is also not looking at the select field, it's taking the number of subtasks from the summary, which, in the real world, is likely to be utter nonsense, it's almost certainly going to be 0 for any issue, so there's no reason the code would go into the loop that creates the sub-tasks.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events