I want to make a workflow script that will template the issue depending on the type of issue. Now my script looks like this, but it doesn't work, what could be the problem?
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Insert default description template for external users'),
guard: function(ctx) {
var issue = ctx.issue;
return !issue.isReported && !issue.becomesReported && issue.description === null;
},
action: function(ctx) {
var issue = ctx.issue;
if(issue.fields.becomes(ctx.Type, ctx.Type.Bug))
{
ctx.issue.description = workflow.i18n("### **Initial state:**") +
"\n\n" +
workflow.i18n('### **Steps to reproduce:**') +
"\n1.\n2.\n3.\n\n" +
workflow.i18n("### **Expectations:**") +
"\n\n" +
workflow.i18n("### **Actual:**") +
"\n";
}
if(issue.fields.becomes(ctx.Type, ctx.Type.Task))
{
ctx.issue.description = workflow.i18n("### **Some text:**");
}
if(issue.fields.becomes(ctx.Type, ctx.Type.Feature))
{
ctx.issue.description = workflow.i18n("### **Some text:**");
}
},
requirements: {}
});