Frustrating experience with workflow creation for scheduled rules
I really don't want to mope, but it's a bummer that a tool that's so powerful as the JavaScript workflow developer is intransparent / hard to debug.
e.g.: I want to create an issue on a cron cycle. Should be simple enough.
However, it's proving to be very difficult, because I'm flying blind. For testing reasons, I've got the CRON to be every minute. and the code runs… but doesn't do anything.
/* eslint-disable */
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var workflow = require('@jetbrains/youtrack-scripting-api/workflow');
exports.rule = entities.Issue.onSchedule({
title: "Tagesbericht",
cron: '0 * * * * ?',
search: 'AD-4',
action: function(ctx) {
const logger = new Logger(ctx.traceEnabled);
console.log("Running", new Date().toLocaleTimeString("de-DE"))
const project = ctx.issue.project;
const summary = `Test`;
const newIssue = new entities.Issue(ctx.assigneeUser.alexandria, project, summary);
logger.log("Issue created", newIssue.idReadable);
const checklistItems = [
"Spazieren",
"Sport"
]
const createDescription = () => checklistItems.map(item => `* [] ${item}`).join("\n\n")
newIssue.description = createDescription();
newIssue.fields["assignee"] = ctx.assigneeUser.alexandria;
newIssue.fields["due date"] = "2026-06-19";
newIssue.fields["status"] = ctx.statusState.Prioritized;
newIssue.fields["type"] = ctx.typeEnum.Tagesbericht;
console.log("Issue created", summary)
},
requirements: {
assigneeUser: {
name: "assignee",
type: entities.User.fieldType,
alexandria: {login: "alexandria"}
},
duedateDate: {
name: "due date",
type: entities.Field.dateType
},
statusState: {
name: "status",
type: entities.State.fieldType,
Prioritized: {name: "Prioritized"}
},
typeEnum: {
name: "type",
type: entities.EnumField.fieldType,
Tagesbericht: {name: "Tagesbericht"}
}
}
});
function Logger(useDebug = true) {
return {
log: (...args) => useDebug && console.log(...args),
warn: (...args) => useDebug && console.warn(...args),
error: (...args) => useDebug && console.error(...args)
}
}Upload id: 2026_06_15_23xWgGCrvEXjkQE4iV9eV8 (file: no_error_thrown.png)
Console shows the first log, but NOTHING IS BEING CREATED.
I'm left with the basic question of why is neither an error thrown / printed, nor the “created” message? Shouldn't it be one or the other?
Please sign in to leave a comment.
Hello,
I'm Stanislav from the YouTrack Team. Thanks for reaching out!
The action stops at this line:
A date field doesn't store text; it stores a Unix timestamp in milliseconds, as documented.
Assigning a plain string stops the rule before the issue is saved, which is why nothing is created. Use the date-time module's dateTime.parse() to convert the date into a timestamp:
This needs the date-time module, so add it to the requires at the top of your rule:
These errors aren't shown in the console, so the way to locate them is to add a
console.logafter field assignment and reproduce the run:The last line that prints in the editor's Console pane tells you which statement failed, so if the rule stops again at another field after the date fix, the same approach points straight to it.
Please feel free to reach out anytime if you have any questions or encounter any issues. Have a nice day!