Cannot set one Custom Field to another Custom Field, what am I doing wrong?
This seems like a simple thing, but I cannot assign my custom field Severity to Priority field. Here's my code:
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onChange({
title: 'If Bug type ticket, map Severity changes to Priority field',
guard: (ctx) => {
return ctx.issue.fields.isChanged(ctx.Severity) && ctx.issue.fields.is(ctx.Type, ctx.Type.Bug);
},
action: (ctx) => {
const issue = ctx.issue;
issue.fields.Priority = issue.fields.Severity;
},
requirements: {
Type: {
type: entities.EnumField.fieldType,
Bug: {
name: 'Bug'
}
},
Severity: {
type: entities.EnumField.fieldType,
ShowStopper: {
name: 'Show-stopper'
},
Critical: {
name: 'Critical'
},
Major: {
name: 'Major'
},
Normal: {
name: 'Normal'
},
Minor: {
name: 'Minor'
}
},
Priority: {
type: entities.EnumField.fieldType,
ShowStopper: {
name: 'Show-stopper'
},
Critical: {
name: 'Critical'
},
Major: {
name: 'Major'
},
Normal: {
name: 'Normal'
},
Minor: {
name: 'Minor'
}
},
}
});
Please sign in to leave a comment.
Hello Matt,
I suppose that you experience the same issue as was discussed in the following thread. Since the fields use different value sets, you see the error. So you can either merge these sets or rewrite workflow as my colleague suggested in the mentioned thread.