ScriptRunner "create a sub-task" script does not set default values for custom fields

Eric Tremblay August 20, 2015

Goal:

  • We want to make it easy for the JIRA users to create sub-tasks;
  • A lot of the information from the parent task needs to be duplicated into the sub-task;
  • We have created self-transitions in specific workflows that just creates a sub-task using ScriptRunner;

Setup:

  • Jira v6.3.9;
  • ScriptRunner v3.1.4;
  • We have defined a custom field called "VDD";
  • VDD is configured with a default value, which is different for each JIRA project we have. This default value is configured through Administration -> Issues -> Field Configurations;
  • Note: VDD is a field that is only available on sub-tasks. It is not available on the parent task (this is configured through JIRA's Field Configurations)

How ScriptRunner is used:

  • In the Post Functions of the self-transition, we add a Script Post-Function, and use the "create a sub-task" script.
  • The "create sub-task" script is copying the information from the parent task to the sub-task, so this meets our requirement. It even copies the information from custom fields shared by both parent and sub-task (like the Tempo Account field).
  • The script is ordered to run just before "Fire a Generic Event event that can be processed by the listeners."

Result:

  • The sub-task is created, and field values are copied (yay!).
  • Problem: The VDD custom field is empty! - it does not use the configuration set for the custom field, associated with the project.
  • If I simply create a sub-task using the JIRA "Create Sub-Task" command, then the VDD custom field has the default value set properly, as per what was configured in Admin->Field Configurations.

Additional notes:

2 answers

1 accepted

0 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2015

I think this is more of a problem with the API. The default values appear on the screen when you are creating an issue, but if you use the API to create an issue, even if you provide no value for that field, it doesn't appear to use the default value configured in the field config scheme. Also seems related to https://jira.atlassian.com/browse/JRA-26896.

I think you will have to duplicate the logic to set the CF in the additional actions section.

I could be wrong, I haven't tried to reproduce.

Eric Tremblay August 24, 2015

Thanks Jamie, will look for a work around. I am thinking of either copying the field from another "template" issue in the project, or pulling on some content from Confluence. Will have to look at this later on though.

dneufeld October 1, 2015

If you find a workaround before I do, please post. I hit the same thing today.

0 votes
eClerx Orion January 4, 2016

Hi Eric , 

Were you able to find a solution for this ?  Please let me know "how to create a subtask"  automatically using groovy can be achieved .

Suggest an answer

Log in or Sign up to answer