I want to prevent users in YouTrack from modifying or adding workitems in the past. They should only add/modify workitems in current day.
In YouTrack workflows i can detect changed Spent time event and prevent users from adding workitem. But I want to get an event when user is modifying workitem in JavaScript workflows. Here is my code:
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: workflow.i18n('Disable editing workitems'),
guard: function(ctx) {
return ctx.issue.fields.isChanged(ctx.ST);
},
action: function(ctx) {
workflow.check(ctx.issue.workItems.added.isEmpty(), workflow.i18n('You can add/modify workitems only in current day.'));
},
requirements: {
ST: {
type: entities.Field.periodType,
name: 'Spent Time'
}
}
});
Datetime conditions are omitted...