Find agile boards connected to an issue

Hello,

Is there a way to check when an issue is removed from an agile board?
I'm trying to change an issue state when the issue is removed from a board e.g by dragging it from the current board to the backlog in the agile board view.

0
1 comment

Hi!

You can do this with a workflow: check board.isRemoved(issue) (or getRemovedSprints(issue) if the issue can sit on several sprints at once) inside an onChange rule's guard, then set the state in the action. Something like:

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

exports.rule = entities.Issue.onChange({
  title: 'Set State when issue leaves the board',
  guard: (ctx) => {
    const board = entities.Agile.findByName('My Board').first();
    return board !== null && board.isRemoved(ctx.issue);
  },
  action: (ctx) => {
    ctx.issue.fields.State = ctx.State.Submitted;
  },
  requirements: {
    State: { type: entities.State.fieldType, Submitted: {} }
  }
});

This needs YouTrack 2024.2 or later. One catch: it only works on regular boards, not a query-based board with sprints disabled, since those don't have a backlog to drag into in the first place.

See docs: Agile.isRemoved.

0

Please sign in to leave a comment.