Workflows to Create Issue


I am having trouble creating a new issue in a workflow, or rather setting its properties. My code is looping through an array of repeating tasks and creating an issue for each. It creates the issues with no problem but for some reason I am not able to set the properties. The workflow message seems to indicate the field is set correctly but when I open the issues created the field is still in its default state. I have tried setting an enum and also a date field and get the same problem for each so I must be using the 'requirements' incorrectly but don't see what I am doing wrong. 


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

var MONTHS = [
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"

var tasks=[
"TaskName": "Load LIM data",
"StartDate": 1,
"EndDate": 2
"TaskName": "Month End SRFA Update ",
"StartDate": 4,
"EndDate": 6
exports.rule = entities.Issue.action({
title: 'Test_fund_date_module',
command: 'test_fund_date_module',
guard: function(ctx) {
return true;
action: function(ctx) {

//get dates
var todaysDate = new Date();
var currentMonth = todaysDate.getMonth();
var currentYear = todaysDate.getFullYear();

//loop though each task and create issue

function createIssue(item){
var newIssueName= currentYear + '-' + MONTHS[currentMonth] + '-' + item.TaskName;
var startDate=new Date(currentYear,currentMonth,item.StartDate);

var newIssue = new entities.Issue(ctx.currentUser, ctx.issue.project,newIssueName,);
newIssue.fields.FundDataState = ctx.FundDataState.Submitted;

requirements: {

FundDataState: {
name: 'Fund Data State',
type: entities.EnumField.fieldType,
Submitted: {
name: 'Submitted'


Comment actions Permalink
Official comment


Since you are creating a new issue that is outside the context, would you please try to use the following syntax: 

newIssue.fields['Fund Data State'] = ctx.FundDataState.Submitted; 

See also -

Should you have any further questions, feel free to contact us.

Comment actions Permalink

That works! Thank you very much. 


Please sign in to leave a comment.