Post function copy field from parent not working when cloning sub-tasks

Martin Burton June 5, 2015

Hi,

We have several post-funtions in the sub-task workflow for the Create action that copy values from various fields in the parent issue.  This includes built-in fields such as Affects Version and Fix Version, plus some custom fields. This works fine when creating new sub-tasks.  However it is not working when we create a clone of a sub-task.  All the fields that should get populated are blank.

JIRA Server 6.1.7

 

Any help would be much appreciated.

Martin.

1 answer

1 vote
William Crighton _CCC_
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.
June 6, 2015

you just have to be sure the changes to the parent issue are preserved (saved) first. put your post functions after the parent is indexed.....4th or 5th default post-function

Ok, guess I should have asked some more questions - first off, give me the usual suspects - JIRA version, JDK version, Script Runner version.

Ok, after asking the correct questions I define your problem as this:

With JIRA v6.1.7 you have subtasks (one or more of the subtask types) using a workflow which contains a post-function in the 'On Create' workflow that copies a value from the parent issue using the Suite Utilities 'Copy value from Other Field' selecting the parent issue as the source and the sub-task as the destination.

When creating a sub-task from the parent issue you see the subtask on-create post-function execute and the sub-task field is populated when the sub-task has been created.

When  you then go into that sub-task and select 'clone', creating a copy of the sub-task, the sub-task field is not populated from the parent issue (I'm guessing that you go in and modify the parent issue field and do not see the changed value in the 'cloned' subtask, cause otherwise it'd just have the same parent value that the first sub-task field had been assigned and you wouldn't know if it came from the parent via the post function or just from the sub-task as part of the clone activity).

Question - did you add the following additional post-function to your sub-task on-create workflow transition? Look at post function #3 immediately prior to #4 (duh) 'Re-index an issue to keep indexes in sync with the database' - see the post function 'Stores updates to an issue (no change history is created)'? Notice how in the screenshot the delete (and edit, though you can't see it) are not selectable? This is a post function that you can add but not remove. Do you have it in your sub-task 'On Create' workflow post-functions?

I had to add it to get any of the 'copy field' post functions to work in the 'on create' transition, but once I added it then fields would be copied on my sub-task regardless of whether I was creating the initial subtask or cloning one I'd already created.

Attachments - storeIssuePostFunction - adding to workflow

store_issuePostFuntion.png

 

subtaskCreateWorkflow.png

And Here I cannot remove it once added....you cannot tell, but the 'delete' and 'edit' options are not enabled.

postfunction-CannotRemoveStoreIssueFunction.png

-wc

Martin Burton June 8, 2015

Do you mean in the post-functions for the sub-task create action? This has the actions to copy the fields from the parent before the re-index. I understood this was required to get the sub-task index correct. I don't see a post-function to re-index the parent. Martin.

William Crighton _CCC_
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.
June 11, 2015

@Martin Burton - I edited my original answer asking how these sub-tasks are being created - is it via a post function in the parent issue's workflow? If so, is that post function being fired prior to the parent reindex post-function? If that is the case then just move your 'create sub-task' post function to after the parent is re-indexed. If not then please reply with more details on your setup - jira version, process description, etc thanks -wc

Martin Burton June 11, 2015

Hi William, We are just using the standard Clone option from the first sub-task to create additional ones. This is not part of the parent issue create or any other transition. As mentioned there are post-functions in the sub-task create that copies the field values from the parent. Creating the parent, first and subsequent sub-tasks are all separate operations. Details of our Jira instance are: JIRA Build : 6.1.7#6163-sha1:94d557d067e7b31a37a03eea89c85612ea7bb3b6 Build Date : Wed Jan 22 00:00:00 GMT 2014 JIRA Installation Type : Standalone Application Server : Apache Tomcat/7.0.29 - Servlet API 3.0 Java Version : 1.7.0_25 - Oracle Corporation Script Runner : com.onresolve.jira.groovy.groovyrunner Version : 2.1.16 Status : enabled Vendor : Jamie Echlin Ltd Description : Script runner plugin for Atlassian JIRA. Thanks for your help. Martin.

William Crighton _CCC_
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.
June 12, 2015

Martin, Ok - guess I should have asked this to start with - what is being used to copy the value from the parent issue? Is it a custom groovy function? Not the suite-utilities 'copy value from field' where you can specify the parent issue as the field source? -wc

Martin Burton June 13, 2015

William, We do use the Copy value from field post-function, with the parent specified as the field source.. Martin.

William Crighton _CCC_
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.
June 23, 2015

@Martin Burton - I updated my answer - did any of this help you at all?

Martin Burton June 24, 2015

Thanks William. I have added the Store issue post-function, and moved create issue to the top. Previously I had Create Issue after all the copy fields as my workaround to get the copies to occur. Now all the fields are populated. However some come from the parent and some from the sub-task being cloned. I need to check which it should be with the user team, and experiment with the order of the post-functions. Martin.

Suggest an answer

Log in or Sign up to answer