Set a Custom Description Based on Team Group
I try setup Custom Description based on Team Group but it dont work.
Code type:
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Insert default description template for QA external users'),
guard: function(ctx) {
var issue = ctx.issue;
return !issue.isReported && !issue.becomesReported && issue.description === null;
},
action: function(ctx) {
ctx.issue.description = workflow.i18n('Описание проблемы:') +
"\n\n" +
workflow.i18n("Воспроизведение по шагам:") +
"\n1.\n2.\n3.\n\n" +
workflow.i18n("Ожидаемый результат:") +
"\n\n" +
workflow.i18n("Визуальная Локация:") +
"\n\n" +
workflow.i18n("Программная Локация:") +
"\n\n" +
workflow.i18n("Заметки:") +
"\n\n";
},
requirements: {
OurTeam: {
type: entities.UserGroup,
name: 'QA'
}
});
Please sign in to leave a comment.
Hello Sergey.
You lost one " } " and specified the wrong type
Information about types here.
requirements: {
OurTeam: {
type: entities.UserGroup.fieldType,
name: 'QA'
}
}
});
I need the description to work only for a specific group of users. since now it works for everyoneIn "requirements", you need to specify which fields and their values are required for the project. You don't need it.
Add a condition to guard:
ctx.CurrentUser.isInGroup("QA");This temp not work too
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Insert default description template for QA external users'),
guard: function(ctx) {
var issue = ctx.issue;
return !issue.isReported && !issue.becomesReported && issue.description === null;
},
action: function(ctx) {
if (entities.UserGroup('QA')) {
ctx.issue.description = workflow.i18n('Описание проблемы:') +
"\n\n" +
workflow.i18n("Воспроизведение по шагам:") +
"\n1.\n2.\n3.\n\n" +
workflow.i18n("Ожидаемый результат:") +
"\n\n" +
workflow.i18n("Визуальная Локация:") +
"\n\n" +
workflow.i18n("Программная Локация:") +
"\n\n" +
workflow.i18n("Заметки:") +
"\n\n";
}
},
requirements: {
}
});
...
return !issue.isReported && !issue.becomesReported && issue.description === null && ctx.currentUser.isInGroup("QA");
action: function(ctx) {
ctx.issue.description = workflow.i18n('Описание проблемы:') +
"\n\n" +
...
Big thanks Ayagudza
Work!
You are welcome!