Time Tracking in workflow - action after workitem added

Answered

Hello,

I need help with creating a workflow that calls an URL endpoint whenever the workitem is added/edited in issue. We need to integrate YouTrack with our reporting system.

3 comments
Comment actions Permalink

Hello Josef, we're ready to help, could you please paste the code that you currently have? What doesn't work there?

0
Comment actions Permalink

Ok, I have:

if(!ctx.issue.workItems.isEmpty()) {

 //do something
}

But this is triggered everytime there is at least one workitem. BUT, I want to handle situation, when work item is added. I also considered state-machite rules but it seems that Time Spent field is special, because it cannot be changed directly (only through adding workitems)...

Could you please give me a hit, how can I handle the change of total spent time of an issue? Thank you.

0
Comment actions Permalink

Hello Josef,

You are right, 'Spent Time' is a special field: when you turn the time tracking on, this field is updated automatically. So, you may use the following check:

`if (ctx.issue.fields.isChanged(ctx.ST))`,

where `ctx.ST` is defined in requirements section:

`ST: {

  type: entities.Field.periodType,

  name: 'Spent Time'

}`

0

Please sign in to leave a comment.