YouTrack Standalone 2021.2 Help

Clone Issue

This workflow contains two action rules that let users clone issues.

Name@jetbrains/youtrack-workflow-clone-issue
Auto-attachedyes
ModulesClone issue (action rule)
Clone issue as draft

Use Case

This workflow is designed to help users make copies of existing issues so they can quickly track activities that are performed on a regular basis. These are written as action rules, so users can perform this operation on the fly, as required.

The rules that belong to this workflow serve different purposes:

  • The Clone issue rule creates issues in a reported state. This means that notification events are triggered as soon as the clone is created. If you need to make any changes to an issue that is created as a clone with this operation, users may receive a second round of notifications.

  • The Clone issue as draft rule creates issue drafts. Notification events are only triggered when you have finished editing the draft and report the issue.

To learn more about clone operations in YouTrack, see Clone Issues.

Rules

This workflow has two rules that let users clone issues in different ways.

RuleDescription
Clone issue

Creates a copy of an issue and reports it in the same project as the original.

This workflow runs when you use the clone command in the Command Window or select the Clone issue action in the issue toolbar.

Clone issue as draft

Creates a copy of one or more selected issues as a new issue drafts instead of reporting them automatically in the original project. You can find the these copies in the list of Drafts when you create a new issue.

This workflow runs when you use the clone as draft command in the Command Window or select the Clone issue as draft action in the issue toolbar.

Clone issue

First, the rule verifies that the issue has already been reported. If true, it creates a copy of the issue in context with the createCopy() method. If successful, YouTrack displays a confirmation message.

Note that the createCopy() method belongs to YouTrack's internal workflow API. When writing your own workflows, use Issue#copy() instead.

var workflow = require('@jetbrains/youtrack-scripting-api/workflow'); var entities = require('@jetbrains/youtrack-scripting-api/entities'); exports.rule = entities.Issue.action({ title: workflow.i18n('Clone issue'), command: workflow.i18n('clone'), guard: function(ctx) { return ctx.issue.isReported; }, action: function (ctx) { var newIssue = ctx.issue.createCopy(); // WARNING! Do not use this method in your workflows. Use Issue#copy() instead workflow.message(workflow.i18n('A clone of the current issue has been created: <a href="{0}">{1}</a>>', newIssue.url, newIssue.id)); } });

Clone issue as draft

First, the rule verifies that the issue has already been reported. If true, it creates a copy of the issue in context with the createDraftCopy() method and saves it as a draft. If successful, YouTrack displays a confirmation message.

Note that the createDraftCopy() method belongs to YouTrack's internal workflow API. When writing your own workflows, use Issue#copy() instead.

var workflow = require('@jetbrains/youtrack-scripting-api/workflow'); var entities = require('@jetbrains/youtrack-scripting-api/entities'); exports.rule = entities.Issue.action({ title: workflow.i18n('Clone issue as draft'), command: workflow.i18n('clone as draft'), guard: function(ctx) { return ctx.issue.isReported; }, action: function (ctx) { var newIssue = ctx.issue.createDraftCopy(); // WARNING! Do not use this method in your workflows. Use Issue#copy() instead workflow.message(workflow.i18n('A clone of the current issue was saved to your list of drafts. <a href="{0}">Edit draft</a>', newIssue.url)); } });
Last modified: 16 March 2021