Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTrack Workflow: Prevent Deletion

I've created a very simple workflow task for a cloud based YouTrack instance. The idea is to prevent (stop workflow) deletion of issues (we'd prefer to keep all issues, even if they were submitted by mistake). The code is provided below.

var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');

exports.rule = entities.Issue.onChange({
  // TODO: give the rule a human-readable title
  title: 'When-issue-is-deleted',
  guard: function(ctx) {
    return ctx.issue.becomesRemoved;
  },
   action: function(ctx) {
     workflow.check(false, 'Do not remove issues, please');
  }
});

Though I believe it should work, when I tried to remove a new just created issue I received no error messages, and the issue was removed.

like image 345
sviklim Avatar asked Dec 03 '25 09:12

sviklim


2 Answers

I'd recommend an easier way - just disable 'Delete issue' permission for the respective roles (https://www.jetbrains.com/help/youtrack/standalone/Create-and-Edit-Roles.html#editing_existing_roles) and users with these roles will not be able to delete issues.

As for becomesRemoved property which doesn't work properly - this is a known issue, please follow this ticket to receive further updates on it: https://youtrack.jetbrains.com/issue/JT-29303.

like image 176
Ana Bartasheva Avatar answered Dec 04 '25 22:12

Ana Bartasheva


I'd recommend an easier way - just disable 'Delete issue' permission for the respective roles (https://www.jetbrains.com/help/youtrack/standalone/Create-and-Edit-Roles.html#editing_existing_roles) and users with these roles will not be able to delete issues.

As for becomesRemoved property which doesn't work properly - this is a known issue, please follow this ticket to receive further updates on it: https://youtrack.jetbrains.com/issue/JT-29303.

like image 30
Ana Bartasheva Avatar answered Dec 04 '25 23:12

Ana Bartasheva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!