State Machine Workflow Multiple Values Fields

I have a workflow, in which I manage all the state changes. Also there is a rule, which forces the user to set a value for my custom field "Extension". This fields war a single value field in the beginning. Now I changed it to a multiple value field.

How can I adapt my state machine workflow to now use a multiple value field, instead of a single value field?

This is my workflow:

var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');

exports.rule = entities.Issue.stateMachine({
title: 'Full TYPO3 project workflow',
fieldName: 'State',
states: {
//--------------------------------------------------------------------------------------------------
'New': {
initial: true,
transitions: {
'open': {
targetState: 'Open'
}
}
},
//--------------------------------------------------------------------------------------------------
'Open': {
onEnter: function(ctx) {
ctx.issue.fields.Assignee = ctx.currentUser;
},
transitions: {
'hold': {
targetState: 'Hold'
},
'customer feedback': {
targetState: 'Customer Feedback'
},
'in progress': {
targetState: 'In Progress'
}
}
},
//--------------------------------------------------------------------------------------------------
'Hold': {
transitions: {
'open': {
targetState: 'Open'
},
'customer feedback': {
targetState: 'Customer Feedback'
},
'in progress': {
targetState: 'In Progress'
}
}
},
//--------------------------------------------------------------------------------------------------
'Customer Feedback': {
transitions: {
'open': {
targetState: 'Open'
},
'hold': {
targetState: 'Hold'
},
'in progress': {
targetState: 'In Progress'
}
}
},
//--------------------------------------------------------------------------------------------------
'In Progress': {
transitions: {
'open': {
targetState: 'Open'
},
'hold': {
targetState: 'Hold'
},
'customer feedback': {
targetState: 'Customer Feedback'
},
'pending review': {
targetState: 'Pending Review',
action: function(ctx) {
var fields = ctx.issue.fields;
fields.required(ctx.Extension, workflow.i18n('Please set an "Extension" value for this issue (TYPO3 extension).'));
fields.required(ctx.Assignee, workflow.i18n('Please set an "Assignee" for this issue.'));
fields.required(ctx.Reviewer, workflow.i18n('Please set a "Reviewer" for this issue.'));
workflow.check(fields.Assignee.login !== fields.Reviewer.login, 'Assignee can\'t review own code, please set another Reviewer!');
}
}
}
},
//--------------------------------------------------------------------------------------------------
'Pending Review': {
transitions: {
'open': {
targetState: 'Open'
},
'fixed (dev)': {
targetState: 'Fixed (DEV)'
},

}
},
//--------------------------------------------------------------------------------------------------
'Fixed (DEV)': {
transitions: {
'released (int)': {
targetState: 'Released (INT)',
action: function(ctx) {
var fields = ctx.issue.fields;
fields.required(ctx.FixVersions, workflow.i18n('Please set the "Fix Version" for this issue.'));
}
}
}
},
//--------------------------------------------------------------------------------------------------
'Released (INT)': {
transitions: {
'live (prod)': {
targetState: 'Live (PROD)'
}
}
},
//--------------------------------------------------------------------------------------------------
'Live (PROD)': {
transitions: {}
}
},
requirements: {
Assignee: {
type: entities.User.fieldType
},
Reviewer: {
type: entities.User.fieldType
},
Extension: {
type: entities.EnumField.fieldType
},
FixVersions: {
name: 'Fix Version',
type: entities.ProjectVersion.fieldType
}
}
});

1 comment
Comment actions Permalink
Official comment

Hello,

I am afraid, the State-machine Rule does not work with multi-value fields. As a workaround, I suggest you crate a separate on-change rule to prevent end-users selecting not-allowed values using the workflow.check method. Should you have any further questions, feel free to contact us.

Please sign in to leave a comment.