Details
-
Bug
-
Status: Done
-
High
-
Resolution: Fixed
-
5.1.0
-
None
-
None
-
ScriptRunner| 5.1.0 |
JIRA Software| 7.4.3 |
-
1
Description
In JIRA you have the ability to automatically set default values for your custom fields via the custom field configuration page. However, if you set a custom field to have default values, they will not be set when creating a sub-task via the ScriptRunner Create Sub-task post-function as you would expect.
Steps to reproduce:
- Create a new custom checkbox field and give it some random options.
- Then configure that checkbox field to only appear on sub-tasks and set the default value of the field:
- Now configure a Create Subtask post-function that executes on a transition of your choice.
- Remember to publish the workflow before exiting
- Create a new issue for testing
- On your newly created issue, click the "More" tab and open the dialog to manually create a subtask. Notice that the values for your custom field are set to the defaults as you would expect.
- Exit that dialog without creating a sub-task and then execute the transition that you attached the Create Sub-task post-function to.
- Notice in the newly created subtask that the default values were not set!
Workaround
In the additional issue actions field, include the following script
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.context.IssueContextImpl def issueContext = new IssueContextImpl(issue.projectId, issue.issueTypeId) def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("CustomFieldName") def fieldConfig = ComponentAccessor.fieldConfigSchemeManager.getRelevantConfig(issueContext, cf) def defaultValue = cf.getCustomFieldType().getDefaultValue(fieldConfig) issue.setCustomFieldValue(cf, defaultValue)