Hi,
I would like to set a custom field back to it's default value when an issue is re-opened. I know how to set a value during a transition and even how to get the current value via a Groovy script but I can't seem to find a way to find the field's default value? Right now we have the default value "hard coded" into a post function but the field's default value changes on a monthly basis so I'd like to be able to update the default value in the Custom Field configuration without having to go and also change all my Post Functions.
Please note that while we have JIRA Misc Workflow Extensions, we don't have Script Runner.
Thanks for the help!
Hi,
finding the default value of a field in Jira is actually overly complicated. It really depends on the type of custom field. If you tell me which custom field type it is, I might be able to provide the appropriate code.
Sorry, I knew I forgot something in my original post! The Custom Field is a "Select List (single choice)"
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can use the following script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.config.FieldConfig
CustomFieldManager customFieldManager = ComponentAccessor.customFieldManager;
CustomField customField = customFieldManager.getCustomFieldObjectByName("select")
FieldConfig relevantConfig = customField.getRelevantConfig(issue);
customField.getCustomFieldType().getDefaultValue(relevantConfig)
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.
I need to do the same thing with both a Multi Line Text Field and a Multiple User Picker. There are multiple Contexts in the Jira instance, too.
Thanks.
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.