I have a customer numeric field called 'minutes spent'.
When a new issue is created I want to set that field to zero, in case the issue is actually cloned from another issue that already has some value in that field.
I've created a post-function that will set the minutes spent field to null, but would prefer to have it set to 0 so that the field will be displayed as zero when the new issue is viewed (and easily updated from the view screen versus having to go into edit screen)
I set the default value for the field to be zero but that had no effect
This script works to null out the field, but again would rather set it to 0.
//Set fields to blank or null in case this issue is being cloned
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
MutableIssue currentIssue = issue
customFieldManager = ComponentAccessor.getCustomFieldManager()
def fieldToSet1 = customFieldManager.getCustomFieldObjectsByName("Minutes Spent")[0]
def fieldConfig1 = fieldToSet1.getRelevantConfig(issue)
fieldToSet1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(fieldToSet1), null), new DefaultIssueChangeHolder())
Search prior questions for a post that showed how to set a numeric field to a fixed value but couldn't find one.