ctx.issue.tags.added.isNotEmpty() should work for the Star tag as well. In particular, the following condition determines whether any new watchers were added:
Can you please share the full workflow code from your side and describe the issue in more detail, how exactly ctx.issue.tags.added.isNotEmpty() doesn't work (whether it returns false or something else happens)?
When I add someone as an Assignee for the Issue, they are added to the Watchers list. At this moment, the Issue gets the ‘Star’ tag and the workflow should be triggered. But it doesn't work.
Thanks for explaining the scenario further. ctx.issue.tags.added.isNotEmpty() indeed only catches explicit tag addition, i.e. when a user manually clicks the “Star” icon within the issue. However, there's no way to detect it from a workflow if it's set implicitly as a result of changing the issue assignee. This ensures that the “Star” tag behavior configured by the user in their profile settings remains unaffected.
In your case, a more fitting solution would be catching the assignee change and making sure the issue is visible to them:
const entities = require('@jetbrains/youtrack-scripting-api/entities');
exports.rule = entities.Issue.onChange({
title: 'Add-assignee-to-issue-visibility',
guard: (ctx) => {
return ctx.issue.Assignee && ctx.issue.isChanged("Assignee");
},
action: (ctx) => {
const issue = ctx.issue;
if (!issue.isVisibleTo(issue.Assignee)) {
issue.permittedUsers.add(issue.Assignee);
issue.addComment(issue.Assignee.fullName + " is added to the issue visibility since they are now the assignee");
}
}
});
Hello,
You can check the following:
Besides that, describe Tag in requirements:
requirements: {Released: {
type: entities.IssueTag,
name: "Released"
}
}
Hello,
Nevermind I found a way to do it.
exports.rule = entities.Issue.onChange({
title: 'Your title',
guard: function(ctx) {
var issue = ctx.issue;
return issue.isResolved && issue.tags.added.has(ctx.Released);
},
action: function(ctx) {
//your action rule
},
requirements: {
Released: {
type: entities.IssueTag
}
}
});
Hope it can helps others.
Hello,
ctx.issue.tags.added.isNotEmpty() only works with normal tags, and when a Star tag is added, this condition does not work.
How to track a Star tag?
Anastasia Bartasheva
Hi Viacheslav Bachynskyi,
ctx.issue.tags.added.isNotEmpty()should work for the Star tag as well. In particular, the following condition determines whether any new watchers were added:Can you please share the full workflow code from your side and describe the issue in more detail, how exactly
ctx.issue.tags.added.isNotEmpty()doesn't work (whether it returnsfalseor something else happens)?Hi Julia Bernikova
Here is the code:
When I add someone as an Assignee for the Issue, they are added to the Watchers list. At this moment, the Issue gets the ‘Star’ tag and the workflow should be triggered. But it doesn't work.
Hi Viacheslav Bachynskyi,
Thanks for explaining the scenario further.
ctx.issue.tags.added.isNotEmpty()indeed only catches explicit tag addition, i.e. when a user manually clicks the “Star” icon within the issue. However, there's no way to detect it from a workflow if it's set implicitly as a result of changing the issue assignee. This ensures that the “Star” tag behavior configured by the user in their profile settings remains unaffected.In your case, a more fitting solution would be catching the assignee change and making sure the issue is visible to them:
Ok, thanks!