Unwanted issue type change when adding sprint to issue

Hi

I wrote the following script to update sprints for subtasks to the sprints of parent issue.

After running script on parents with "User Story" type which have some subtasks with "Task" type, for some unknown reason all subtasks are changed to "User Story"!

I didn't change task type in my script and I want to inherit only sprint and not type.

 

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

exports.rule = entities.Issue.onChange({
  title: 'Sprint-inheritance',
  guard: (ctx) => {
    return (ctx.issue.links['parent for'].isNotEmpty() && !ctx.issue.isResolved && ctx.issue.sprints.isChanged);
  },
  action: (ctx) => {
    const issue = ctx.issue;
    issue.links['parent for'].forEach(function(subtask) {
    if (!subtask.isResolved) {
     issue.sprints.forEach(function(sp) {
        console.log("Adding " + subtask.id + " to sprint: " + sp.name);
          subtask.sprints.add(sp);
    });
}
    });
  },
  requirements: {
    SubtaskOf: {
      type: entities.IssueLinkPrototype,
      name: 'Subtask',
      outward: 'parent for',
      inward: 'subtask of'
    }
  }
});
1
3 comments
Hello,

I'm Lena from YouTrack. I will help you.

This workflow looks correct and should not change the Type field. I recommend you ensure that you don't have other workflows which change the Type field. For this, please open the Projects -> you_project -> Workflows page and try to disable the workflow rules one by one and after each disabling, test this scenario again.

I'm looking forward to seeing your results.
1

I disabled all workflows (default workflows) and only Sprint-Inheritance was enabled, but unfortunately it didn't help.

All subtasks with task type are changed to storyboard, if I change sprint on parent which is a storyboard.

0
Hello,

Unfortunately, I could not reproduce the issue in our sandbox - your workflow works correctly in the empty project. Could you please create a ticket in our Support Center (https://youtrack-support.jetbrains.com/hc/en-us/requests/new)? I will ask for additional information about your settings (this information may be sensitive).
0

Please sign in to leave a comment.