Hi all!
When creating a subtask, need to add the value +1, depending on the number of subtasks in the current project. Now the value is added based on all projects.
I know that project = projectname but the script should be universal
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.IssueManager
import org.ofbiz.core.entity.GenericValue
import com.atlassian.jira.issue.Issue;
import org.apache.log4j.Logger
import com.atlassian.jira.project.Project
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
GenericValue project = issue.getProject()
Issue issue = issue
def key = issue.getKey()
def jql = "parent = " + key
def query = jqlQueryParser.parseQuery(("issuetype = Sub-task"))
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
issue.summary = issue.parentObject.summary + ' Sub-task'+ (results.total+1)
log.warn("Total issues: ${results.total}")
@Dmitry P
You need add +1 to summary okay I understood this.
You wrote " depending on the number of subtasks " I didn't understand this part.
Please provide more information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.