Clone does not fire workflow

We have a workflow that when we create an issue of type User Story, that creates a number of sub-tasks.  

We noticed recently that when we CLONE an issue of type User Story, the workflow does not fire as we expected it to.  The sub-tasks do not get created as we expect.  

What are we missing?  Do we need to modify the workflow “@jetbrains/youtrack-workflow-clone-issue” to perform the same functions?  

Or is there some other method that we should pursue?

 

Thanks in advance!

 

 

 

0
3 comments

Hi!

Cloning doesn't “create” a new issue, so it may not trigger the workflow's execution if “issue creation” serves as the condition there. As a simple workaround, you can modify the default cloning workflow like so:

  action: function (ctx) {
    const newIssue = ctx.issue.createCopy(); // WARNING! Do not use this method in your workflows. Use Issue#copy() instead
    newIssue.addTag("cloned");
    workflow.message('A clone of the current issue has been created: <a href="{0}">{1}</a>', newIssue.url, newIssue.id);
  }

This will attach the “cloned” tag to the cloned issue. As this will actually produce a change, you can use that tag to trigger another workflow. As a visual example:

This will immediately remove that tag and update the issue description. If you have your workflow in JS, you can use the hasTag method for the same purpose. You can provide the logic for creating new issues in the action section. Let me know if this doesn't seem clear.

1

Thank you, Stanislav.  I'll give that shot.

0

Please sign in to leave a comment.