We would like to categorize better time spent and currently work type is not required when entering time. How do we enforce it?
Would be nice to require description as well. I checked general time entry settings, and checked project level. It allows to add/remove fields but there is nowhere about making it required
We would like to categorize better time spent and currently work type is not required when entering time. How do we enforce it?
Would be nice to require description as well. I checked general time entry settings, and checked project level. It allows to add/remove fields but there is nowhere about making it required
Share Improve this question asked Mar 14 at 19:56 katitkatit 17.9k36 gold badges135 silver badges267 bronze badges1 Answer
Reset to default 0To achieve this, you can create a custom workflow written in JS that will use the workflow.check() method. This will prevent the transaction when the requirement is not met.
Here is an example:
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: 'Require-work-item-type',
guard: (ctx) => {
const issue = ctx.issue;
return issue.workItems.added.isNotEmpty();
},
action: (ctx) => {
const issue = ctx.issue;
const workItem = issue.workItems.added.first();
let hasWorkItemType = workItem.type ? true : false;
workflow.check(hasWorkItemType, 'Work item type is required!');
},
requirements: {
}
});