Get agile board and sprint of an issue

Hello,

How can I get the board name and sprints of an issue ?
Is it also possible to set a sprint and a board to an issue ?

Thanks in advance
Regards

5 comments
Comment actions Permalink
Official comment

Hello,

You can see the board name and the sprint name on the full view issue page:

To go to the board, just click on the board name. 

As for your second question - yes, you can set a board and a sprint to an issue. Click the "+" icon near the "Boards" (see the screenshot above) and enter the board name. Besides that, you can add an issue to the board and to the sprint via commands: Board <board name> <sprint name> (here is the doc: https://www.jetbrains.com/help/youtrack/incloud/Command-Reference.html#agile-board-commands) For more options of assigning issues to sprints (including automatic assigning using queries) please refer to https://www.jetbrains.com/help/youtrack/incloud/Sprint-Options.html#agile-board-with-sprints.

 

 

Comment actions Permalink

Oh sorry I meant with a javascript workflow. The idea for us is to automatically add an issue of type Epic to a 3 months sprint on a dedicated board. We use YouTrack 2017.3 TPR-20: Website development.

We set up the board to automatically add every new issue to the sprint but US, Bugs and Tasks are also automatically added. We tried a workflow and looked for a log on issue.sprints and issue.fields.sprint but the Set is empty while the issue is visible on the board.

Thanks for your help

 

 

0
Comment actions Permalink

Hello,

 

Here is what we came up with

/**
* This is a template for an on-change rule. This rule defines what
* happens when a change is applied to an issue.
*
* For details, read the Quick Start Guide:
* https://www.jetbrains.com/help/youtrack/standalone/2017.3/Quick-Start-Guide-Workflows-JS.html
*/

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

exports.rule = entities.Issue.onChange({
// TODO: give the rule a human-readable title
title: 'Subtask-test',
guard: function(ctx) {
return ctx.issue.becomesReported && ctx.issue.fields.Type.name == 'Epic' || (ctx.issue.links['subtask of'].isNotEmpty() && ctx.issue.links['subtask of'].first().fields.Type.name == 'Epic');
},
action: function(ctx) {
var issue = ctx.issue;

var quarter_created = quarter_of_the_year(issue.created);
var year_created = new Date(issue.created).getFullYear();
var sprint_name = 'Q' + quarter_created + ' ' + year_created + ' Roadmap';
var board_to_assign = entities.Agile.findByName('Roadmap').first().findSprintByName(sprint_name);

issue.sprints.add(board_to_assign);

function quarter_of_the_year(date) {
var month = new Date(date).getMonth() + 1; //Returns the month from 0-11
return (Math.ceil(month / 3));
}
},
requirements: {
Type: {
type: entities.EnumField.fieldType,
},
SubtaskOf: {
type: entities.IssueLinkPrototype,
name: 'Subtask',
outward: 'parent for',
inward: 'subtask of'
}
}
});

Basically we are looking for the board and sprint the issue is supposed to be linked with and try to add it to the issue. But it doesn't work !

issue.sprints.add(board_to_assign) throw this error : Cannot set value to custom field Sprints
and if we try issue.fields.sprints.add(board_to_assign) it throws this error :TypeError: Cannot call method "add" of undefined 

Can you please give us a hand on that ?

Thanks

0
Comment actions Permalink

Hello,

Sorry for the delay.

Please try the following:

issue.applyCommand('add Board ' + <board_name> + 'Sprints ' + <sprint name>, ctx.currentUser);

So in your case it should look like this:

issue.applyCommand('add Board Roadmap Sprints ' + sprint_name, ctx.currentUser);

Please let me know if it helps. 

 

0
Comment actions Permalink

Hello,

Thanks a lot it does the job ! Just had to adapt a little the issue.applyCommand but was the good method.

Regards

0

Please sign in to leave a comment.