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

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 vote

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.

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.

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

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,226 views 14 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot