Automatically log work when status changed via Automation Rule
Asked by Muhamad Aliff Bin Sabri:

I was trying to create an Automation Rule which will log the work once the status transitioned. For example, from "In progress" to another status. However, it shows me this type of error.

![automation rule.PNG](/t5/image/serverpage/image-id/150140iD17EF7958514813C/image-size/large?v=v2&px=999 "automation rule.PNG")


Answers:
author: Bill Sheboy
body: Hi [@Muhamad Aliff Bin Sabri](/t5/user/viewprofilepage/user-id/4443255) -- Welcome to the Atlassian Community!

You note seeing an error, and I do not see an error in the image you posted. What are you seeing that is not working?

Best regards,  
Bill

comments: author: Muhamad Aliff Bin Sabri
body: Good day [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

The objectives is to show a time spent per status by having a minus of Now() and time when timer start ticking. I try to force log work in every issue transitioned by having above formula. But I was getting this error instead.

![automation rule error 2.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/150911iA347CA1BE1762107/image-size/large?v=v2&px=999 "automation rule error 2.PNG")


author: Bill Sheboy
body: Hi [@Muhamad Aliff Bin Sabri](/t5/user/viewprofilepage/user-id/4443255)

If you just need to see time in status, I recommend instead using Jira's version of the control chart: <https://support.atlassian.com/jira-software-cloud/docs/view-and-understand-the-control-chart/>

If you still want to log the time instead, I do not believe you can query the prior worklog entry to find that difference. Instead you might need:

* a custom field to capture the last date/time a status transition happened;
* calculate the difference from {{now}} to get your work log, time spent value;
* and then update the custom field to get ready for the next transition


author: Muhamad Aliff Bin Sabri
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

If a custom field need to be created, what is the correct way to do it to keep the time track?


author: Bill Sheboy
body: I believe I noted the steps you need above. Please look here for more information about the date/time diff() calculations: <https://confluence.atlassian.com/automation/date-and-time-functions-993924864.html>

What have you tried so far? If you have your updated rule, please post that so the community can offer suggestions. Thanks!


author: Emre Toptanc? _OBSS_
body: Hello [@Muhamad Aliff Bin Sabri](/t5/user/viewprofilepage/user-id/4443255)

If you are doing this for cost tracking, I don't recommend creating worklogs based on workflow transitions since it will probably produce inaccurate data. People usually don't work in a first-in-first-out manner so worklogs will just show you status time, which will be different the actual time spent on it. Status time data is already available in each issue's history. Also, your automation rule will not consider your working hours while creating worklogs so the results will probably be even more inaccurate.

In case you are OK with using a marketplace app, our team at OBSS built [**Time in Status**](https://marketplace.atlassian.com/1211756) app for this exact need. It is available for Jira Server, Cloud, and Data Center.

Time in Status allows you to see how much time each issue spent on each **status** or assigned to each **assignee** . You can also combine statuses into consolidated columns to see metrics like **Ticket Age, Resolution Time,****Cycle Time,** or **Lead Time**.

The app has custom calendar support so you can report on status durations based on your working hours (excluding non-working hours and weekends)

You can calculate **averages** and **sums** of those durations grouped by the issue fields you select. (For example, see the total InProgress time per Epic or average Resolution Time per issue type).

![tisCloud_StatusDuration_LeadTime_with Estimates.png](https://community.atlassian.com/t5/image/serverpage/image-id/151111i364D79578EFECB1B/image-dimensions/165x74?v=v2 "tisCloud_StatusDuration_LeadTime_with Estimates.png") ![tisCloud_StatusDuration_LeadTime_Average.png](https://community.atlassian.com/t5/image/serverpage/image-id/151112i84FF7E5B503925B4/image-dimensions/182x61?v=v2 "tisCloud_StatusDuration_LeadTime_Average.png")![tisCloud_StatusDuration_LeadTime_Chart.png](https://community.atlassian.com/t5/image/serverpage/image-id/151113i531E32630B65A762/image-dimensions/156x74?v=v2 "tisCloud_StatusDuration_LeadTime_Chart.png")

The app calculates its reports using already existing Jira issue histories so when you install the app, you don't need to add anything to your issue workflows and you can get reports on your past issues as well.

Time in Status reports can be accessed through its own reporting page, dashboard gadgets, and issue view screen tabs. All these options can provide both calculated data tables and charts.

Using Time in Status you can:

* See how much time each issue spent on each status, assignee, user group and also see dates of status transitions.
* Calculate averages and sums of those durations grouped by issue fields you select. (For example, see average InProgress time per project and per issue type.)
* Export your data as XLS, XLSX, or CSV.
* Access data via REST API. (for integrations)
* Visualize data with various chart types.
* See Time in Status reports on Jira Dashboard gadgets

<https://marketplace.atlassian.com/1211756>

EmreT


Tags: jira

jira-server

jira-service-management

jira-service-management-server

server