Is it possible to increment a custom number field in a post function?
I tried it with Update Any Issue Field (JSU) function, but it only let's me set it to one specific value, but not to currentValue+1.
An example of scriped postfunction to increment a custom number field:
import com.atlassian.jira.ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.CustomFieldType
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.IssueManager
CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()
// In "customfield_15201" replace 15201 by the ID of your custom number field
CustomField cf = cfManager.getCustomFieldObject("customfield_15201")
Double val = issue.getCustomFieldValue(cf) as Double
if (val)
val = val + 1
else
val = 1
issue.setCustomFieldValue(cf, val)
Hi Andréas,
JMWE has a specific post-function for that, but you can also achieve the same with other apps such as ScriptRunner and a little code for example.
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.