Post-function in workflow works fine during create, but fails during clone
Asked by Julie Leonard:

We have been successfully using a story workflow that presents a pre-populated template for the Description and Acceptance criteria fields when creating a new story. A post-function copies the pre-formatted custom description and acceptance criteria field contents to the standard JIRA fields and then creates the issue with that.

When I try to use the built-in Clone function (off the three dots), it fails saying I have to execute the post function "create issues originally" first. But doing that breaks the functionality during the Create process.

I then tried to build a triggered automation copying the description and acceptance criteria fields from the trigger story, but those two fields always come across with the boilerplate preformatted text only. I think I am in some crazy situation where I would need to copy the trigger story Description and Acceptance criteria fields to the cloned preformatted custom fields and then the creation workflow would do the magic of moving that content correctly.

I cannot for the life of me figure out how to write the "smart" code to make that happen or how to make the built-in clone work. Any help would be much appreciated.

![image.png](/t5/image/serverpage/image-id/329597i804D4F5197C98320/image-size/large?v=v2&px=999 "image.png")


Answers:
author: Kuan Yi Ming _ServiceRocket_
body: Hi Julie,

The Create Issue transition in any workflow comes with these three post-functions:

1. Creates the issue originally.
2. Re-index an issue to keep indexes in sync with the database.
3. Fire a Issue Created event that can be processed by the listeners.

Any post-function you create in the workflow should ideally be placed *below* the "Creates the issue originally" post-function.

Regards  
Yi Ming

comments: author: Julie Leonard
body: Hello Yi Ming - thank you for your answer.

I made the change you suggested![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/330268i97C20D0FEF826B52/image-size/large?v=v2&px=999 "image.png")

It still works correctly during the creation process.

The error, I previously incurred during the built-in cloning no longer appears.

However, the cloned issue doesn't show the description and acceptance criteria from the source story, but the boilerplate of a brand new story. I assume that is because it pulls the pre-populated versions into the cloned story after the creation of the clone.

This seems like a chicken and egg scenario. :-(

Do you or anyone else have any other suggestions?


author: Julie Leonard
body: BTW - While I would prefer to use the built-in clone functionality, as a workaround, I figured out a way to perform the clone with automation.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/330271i52D55C25B5238D07/image-size/large?v=v2&px=999 "image.png")


author: Kuan Yi Ming _ServiceRocket_
body: Hi Julie,

It should be possible to have additional post-functions in a workflow that copy additional fields using complex logic that determines if a created issue is a cloned issue. This will almost certainly require a third-party app on the Atlassian Marketplace to achieve, such as [JMWE](https://marketplace.atlassian.com/apps/292/jira-misc-workflow-extensions-jmwe?hosting=cloud&tab=overview).

Regards  
Yi Ming


author: Julie Leonard
body: Thank you, Yi Ming.

I checked out that component and it may help with that and other automations. Thank you so much.

I think for now, I'll stay with the custom automation until we find the need for additional post-functions where that add-on may be useful.

Thank you so much for your help in prodding my brain to look for alternate solutions.

Best,

Julie


Tags: cloud

jira-cloud