Hi,
I have multiple projects configured under Jira.
Some times we clone an issue and move to other project. I want to have all these issues numbered rather than using the Key .
Is there any way to have all these issues when created with a unique number.
When an issue is cloned it should start with the next number and this number should be assoiciated with it always irrespective of moving this cloned issue to another project.
Any help will be appreciated.
Regards,
Allan T
Hello Allan,
Welcome to Atlassian community!
The ability to add customized Issuekey number was requested a while ago to be implemented on JIRA, however, since it is ordered in the same way as the database id, this action proved to be hard to implement cause the database Id is related to the issuekey.
It would require a restructure in the way the issue key is created to avoid incoherencies, so our developers have decided not to pursue it in the near feature:
That been said, you can achieve this same behavior by using a number custom field and any third-party apps to increment it every time an issue is created.
My suggestion would be to use Scriptrunner add-on where you can configure something similar to the following script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.search.SearchProvider// get all the used numbers so far
def query = ComponentAccessor.getComponent(JqlQueryParser).parseQuery("project = JA AND 'Numbers' is not EMPTY ORDER BY 'Numbers' DESC")
def results = ComponentAccessor.getComponent(SearchProvider).search(query,ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),new PagerFilter(1))
int maxNumbers = 0
CustomField cField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Numbers")// get the highest used number
for(Issue documentIssue: results.getIssues()){ maxNumbers = documentIssue.getCustomFieldValue(cField) as Integer }
// set the new number
def newNumbers = ++maxNumbers as String
issue.setCustomFieldValue(cField, newNumbers)
For more information about the proposed option, you can check this answer.
Let me know if this information helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This piece of code does not work for Jira 8.0.0
Could you please let me know what would be the right import and code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.