add submitter as watcher

I'd like to add the person that submits a ticket as a watcher automatically. I see in http://forum.jetbrains.com/thread/YouTrack-411 something that looks like it should work but I'm getting warnings/errors with this script:


rule AddSelfAsWatcher

when <issue created or updated> {
  loggedInUser.watchIssue(issue);
}


The error I'm getting loading in to the test youtrack instance is
"missing name after . operator (Default Watcher->AddSelfAsWatcher#4)"

I'm not sure what I'm missing here.
5 comments
Comment actions Permalink
Did you create at least one project in Youtrack and download workflows/custom fields schema into Workflow Editor?

Since Yourtack 4.0 you can user 'becomesReported()' trigger:
rule auto-watch 
 
when becomesReported() { 
  loggedInUser.watchIssue(issue); 
}
prettyPrint();
0
Comment actions Permalink
We are on a hosted instance that is still on 3.3.1

Will we need to wait for the upgrade to get this feature or is there a way with the previous 3.3 releases?

Thanks for any info
0
Comment actions Permalink
You can use isReported() method but a rule will be invoked on every change in issue draft.

Note, Youtrack inCloud will be upgraded to version 4.0 pretty soon.
0
Comment actions Permalink
Hi all,
I was able to get the original rule (I had to create a new workflow and stateless rule which had the 'when' line pre-populated, then type -not paste- this code in the body in or to get the workflow editor to stop throwing bogus errors):
Code
rule AddSelfAsWatcher

when <issue created or updated> {
  loggedInUser.watchIssue(issue);
}
prettyPrint();

But, when I go to remove myself from an issue with the command:
Code
remove watcher <user_name>
prettyPrint();

I am still a watcher. Which means I am being re-added as a result of removing a wacther and thus updating the issue?

Is there a way to allow users to remove themselves from the watch list with this rule in place?
0
Comment actions Permalink
I am still a watcher. Which means I am being re-added as a result of removing a wacther and thus updating the issue?

Yep, this rule has empty condition to invoke (<issue created or updated>), so it's invoked on any issue change.

To avoid this behavior you have to add some condition on the rule, e.g. becomesReported() to watch creating issue:
rule auto-watch 
 
when becomesReported() { 
  loggedInUser.watchIssue(issue); 
}
prettyPrint();
0

Please sign in to leave a comment.