add work command is assigned to different user

I'm back with another Time tracking problem.
We have implemented automated time tracking depending on issue state.
When issue got state "In progress", Timer time is marked and when finished add work command is executed.
That works pretty well when every user change states by himself.

But: we have also rule that if any issue remains in state In progress later than 18:00, state is transfered from state In progress back to state Open to stop timer. And there is problem - when state change is triggered by schedule rule, add work command is "executed" by me as project admin and Time tracking record work to be done by me, not by assignee. Why? Is there any way how to say "add work User Development Today Automaticaly stopped work"? As I know, there is no possibility to add work to different user ... ? But in this case that is not me who execute command "add work", that is scheduled rule and I supposed that it will be assigned to assignee.
Mariya Davydova
Comment actions Permalink
Official comment


The common solution in this case is to modify a corresponding workflow slightly: there is a command issue.apply('add work item ...') in each workflow that supports automatical adding of work items. All you need to do is to add a user (issue.Assignee) as a second parameter of this method call (and some other user in case of Assignee is not set for a particular issue).

Comment actions Permalink
Hello Stanislav,

Schedule rules excute under the user who uploaded target workflow.
Let me think about the workaround for your case.

Thank you.
Comment actions Permalink
Thx, it will be nice if You find out any workaround. It's quite important for us.
Solution might be to count Spent time from Timer time and current time using some rules like
  • if Timer time started today, count all time as spent solving problem
    - exclude weekends
  • the day the Timer time has been started count max.8 hours and max. until 18:00
  • the current day count max.8 hours and max. from 7:00 ...
  • Other days count max. 8 hours daily ...
But I'm not sure if there are any usefull routines for work with dates? And another question - if I write some routine like that, is there any possibility how to use it in different workflow scripts another way then copy - paste?
Thank You.
Comment actions Permalink


Was there an update/workaround for this? We currently are re-evaluating YouTrack again and noticed this issue when I put another user's issue into Fixed status; it showed up as my time being logged by me, instead of the assigned user.


Thank you in advance!

Comment actions Permalink

Coool, thanks Mariya!

I'm a total newbie  - so using the default start/stop timer I tried to edit that workflow but am doing something dumb and can't get it to work. Would you be able to give me an example on how you would edit that?




Mariya Davydova
Comment actions Permalink


In a 'Stop timer' rule there is a line:

    `issue.applyCommand(l10n ( add work Today  {days + ""} d {hours + ""} h {minutes + ""} m ) + " " + l10n ( The work item automatically added by the timer. ));`

I would replace it with the following code:

    `var user = issue.Assignee;`
    `if (user == null) {`
      `user = loggedInUser;`
    `issue.applyCommand(l10n ( add work Today  {days + ""} d {hours + ""} h {minutes + ""} m ) + " " + l10n ( The work item automatically added by the timer. ), user);`

Note setting this user variable as a second argument in an `issue.applyCommand` method call.


Please sign in to leave a comment.