In new editor you can use issue.fields.sprints, which returns set of sprints. You can also find a sprint using given you have an Agile entity it belongs to (agile.findSprintByName).
In old editor you can use issue.sprints.
Alternatively, you can call issue.applyCommand() to manipulate sprints.
It's a know issue related to toString representation of the Set, meaining that toString does not return anything meaningful. You can try iterating through the elements printing name of the each one.
I am looking for something similar but not even sure if it is possible. I am trying to create a workflow that will run at 8am each day and grab any non-closed tickets with a populated custom date field (ETD to QA) and attach them to the appropriate board (our boards are set up for each month). I am trying to learn the new editor and JSON in the process, so this is becoming quite a hurdle. Can I utilize the issue.fields.sprints and have it match the date in the ticket to the timeframe in the sprint so it knows which board it goes to, or is this not an option?
In new editor you can use issue.fields.sprints, which returns set of sprints. You can also find a sprint using given you have an Agile entity it belongs to (agile.findSprintByName).
In old editor you can use issue.sprints.
Alternatively, you can call issue.applyCommand() to manipulate sprints.
Thank you for your reply. When using Kanban style boards, it seems that issue.fields.sprints is always empty. For instance, in my new workflow I have:
action: function(ctx) {
var issue = ctx.issue;
console.log(issue.fields.sprints);
}
And when I move the issue around on my board, the console shows:
It's a know issue related to toString representation of the Set, meaining that toString does not return anything meaningful. You can try iterating through the elements printing name of the each one.
Ah, ha! Thank you!
I am looking for something similar but not even sure if it is possible. I am trying to create a workflow that will run at 8am each day and grab any non-closed tickets with a populated custom date field (ETD to QA) and attach them to the appropriate board (our boards are set up for each month). I am trying to learn the new editor and JSON in the process, so this is becoming quite a hurdle. Can I utilize the issue.fields.sprints and have it match the date in the ticket to the timeframe in the sprint so it knows which board it goes to, or is this not an option?
Thanks!
Ken,
If I get your use-case correct, it is possible. You need to do the following steps:
1. Having a date field value, get a month from it: new Date(value).getMonth() will return a value from 0 to 11 (see https://www.w3schools.com/jsref/jsref_obj_date.asp).
2. Map this value to the name of you sprint (it is something you define).
3. Find a corresponding sprint using smth like entities.Agile.findByName('Testers board').findSprintByName('<the name you've calculated>') (see https://www.jetbrains.com/help/youtrack/standalone/2017.3/v1-Agile.html#methods)
4. Add this sprint to issues sprints: issue.fields.sprints.add(foundSprint).