Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Development (JIRA): How to add +1 to a summary

Dmitry P February 28, 2019

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


 

1 answer

0 votes
Jamil Rahimov
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.
March 18, 2019

@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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events