Edited Stopwatch-style Work Timer not Working
I'm having an issue with the stopwatch-style timer workflow where after updating the line of code detailed in the documentation here under the section Synchronization with Time Tracking. I want the stopwatch timer to track the time regardless of work days or time limits, so I changed the following line of code as directed in the documentation from:
let duration = issue.project.intervalToWorkingMinutes(issue.fields.TimerTime, Date.now());
to
let duration = workflow.minutesBetween(issue.fields.TimerTime, Date.now());
When I use the workflow with this update (starting and stopping timer) I get the following error in the workflow console:
Processing Issue ISSUE-##:
TypeError: workflow.minutesBetween is not a function
<js> action(scripts/@jetbrains/youtrack-workflow-standalone-work-timer/stop-timer.js:29:1252-1310)
<js> :anonymous(ctx.js:382:11860-11876)I have verified that minutesBetween() is NOT present in youtrack-scripting-api.workflow as the documentation states.
Reverting back to the original line of code, the workflow works as expected as long as the timer's range falls within “working hours”.
If the documentation is correct, how do I get this to work with minutesBetween()? If the documentation is not correct, what are other possible solutions?
Please sign in to leave a comment.
Hi,
I'm Sergey from the YouTrack Team. Thanks for reaching out!
The documentation is indeed incorrect in this case. The
workflow.minutesBetween()method doesn't actually exist in the YouTrack scripting API. I've submitted a task to our documentation team to remove the references to this non-existent method.As an alternative, you can create your own calculation logic using standard JavaScript capabilities. Here's an example:
This is just a basic example. You're free to customize the calculation logic to match your specific requirements for tracking time outside of working hours and time limits.
Let me know if you have any questions!
Thanks Sergey!