Hi ,
I want to have a custom field that should generate number sequence starting from given value and iterate over next issue creation.
E.g Starting Value=4000
My first ticket in Project should have value 4001, TEST-2 as 4002, TEST-3 as 4003 and so on.
I tried to create using Scripted field in Scriptrunner but it is not working. Value are not stored in Scripted field, So i cant take value and add+1 for next ticket.
Could you help in generating sequence of numbers iterating over tickets using scriptrunner Behaviour or Scripted Field
import com.atlassian.jira.issue.Issue
import org.apache.commons.lang3.StringUtils;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def key=issue.getKey()
log.error(key)
def cctype = customFieldManager.getCustomFieldObject('customfield_1500')
LazyLoadedOption cctype_value=(LazyLoadedOption)issue.getCustomFieldValue(cctype)
String value=cctype_value.getValue()
log.error("Value"+value)
def startID = customFieldManager.getCustomFieldObject('customfield_1503')
def startvalue=issue.getCustomFieldValue(startID)
log.error("startvalue"+startvalue)
log.error(cctype_value.getClass())
log.error("Value1:")
if (value=="Development"){
log.error("Value2:")
def ccnid = customFieldManager.getCustomFieldObject('customfield_12501')
//def ccnid_value=issue.getCustomFieldValue(ccnid)
log.error("ccnid"+ccnid)
return (8000).toString()
//String stringToConvert = String.valueOf(ccnid_value);
//Long convertedLong = Long.parseLong(stringToConvert);
// log.error(convertedLong)
// return (convertedLong+1l).toString();
}
I have one jira version ...i want increase version number only how it's possible do you have any idea about on this.
my version is like : 2022.11.0 - project v33.0.0
i want to increment in this manner : 2022.12.0 - project v33.1.0
2023.01.0 - project v33.2.0
Could you please help me out on this.
Hello ,
You can us the ID of the ticket to increment the counter but you'll need to set this value on every ticket to do like this.
Since scripted field are not fixed (they're calculated when issue load) you can't even try to get the previous value and increment it.
I'm afraid they're no real solution to do this without having the field on every issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Florian PEREZ Is there any other way to define it using Scriptrunner Behaviour or other way?
How is the Jira Ticket(Jira Key) is incremented. Could we use same logic?
Thanks,
Tamil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ticket number are stored in Database. You can't use the same logic since the scripted filed is calculated so let imagine what you can do and why it's not possible to think this way :
You can set a hard value on DB (lets say 4000)
Every time you want to set the field on an issue you take the value and then you increment the value on the database ( for the future use ) ( so you say to you issue you value is the one in the database [4000] and increase the value of the one in the database by one [4001])
If you look to your issue you will see that the value is 4001, because everytime you look at the issue the field is calculated. No value are stored.
So you can't use Scripted field for sure.
On the other side customfield store value, so maybe doing a script based on a customfield can do the trick.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.