Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Automation: logged() returns nothing when assigned to a custom field

Dmytro Danylov March 27, 2023

Hello,

I created a custom Number field and want to supply into it the total number of hours logged within a current month.

All seems to work (no failures) but the custom field always shows "None".

The expression used in Automation is: 

{{logged("worklogDate >= startOfMonth()", "worklogDate <= endOfMonth()")}}

 

Add-ons role has all the permissions.

Any ideas on what could be wrong?

1 answer

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 27, 2023

Hello @Dmytro Danylov 

Can you please show us the entire Automation Rule? Often when something doesn't work as expected it can be traced to the context in which the step is running.

Can you show us the Audit Log for an execution of the rule?

Dmytro Danylov March 27, 2023

Hi @Trudy Claspill ,

Sure, please see below. Let me know if other info is needed.

Screenshot 2023-03-27 at 21.49.18.pngScreenshot 2023-03-27 at 21.49.25.png

Here's execution log:

Screenshot 2023-03-27 at 21.51.26.png

Here are the worklog records on the ticket:

Screenshot 2023-03-27 at 21.52.28.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 27, 2023

Thank you for showing us the rule.

Where did you get information about the logged function you are trying to use in the Create Variable action? I am not familiar with that function.

Dmytro Danylov March 27, 2023

Good point, there was a reference on the web, but I can't find it now.

Is there a way to use some other command/function to achieve the same result?

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 27, 2023

Natively Jira doesn't have a function to select worklogs that are within a specified date range. 

What problem are you trying to solve by recording in the issue a total amount of time logged for an issue for the "last month"?

Could you accomplish your ultimate goal by using a third party app that would add functionality that helps you report on the time logged per issue in a specified date range?

If you must record the monthly total in a custom field in the issue, you could potentially create automation rule(s) that are triggered by the logging of work, deletion of worklogs, and editing of worklogs and use those to immediately update a Month Total Time field.

Dmytro Danylov March 28, 2023

I am sure there are third party apps available, but I was hoping to solve the riddle using Jira standard tools.

Referring to your above suggestion, what function could I use to update Month Total Time field?

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 28, 2023

You would use the Automation for Jira feature.

Automation rules have a variety of Triggers, Conditions, and Actions available. You would start by selecting the Work Logged trigger.

You could then add steps (conditions/comparison) to determine if the Work Log is within the time frame that you want to add to your Total Time.

You would then add an Edit action to update your Total Time field, adding to it the value of the current worklog.

The tricky part is that the new work log is going to be for this month, not last month. So you might need two fields; one for "last month" and one for "this month". You could write an Automation Rule to roll over the value from "this month" to "last month" when a new month starts.

And you have to decide what you want to do when work log entries are edited or deleted, if those actions are allowed in your system.

 

None of this will help you calculate the total time for last month retroactively. This would only help you going forward.

 

Another option to look at is using the REST API to extract work log information.

 

You didn't tell us what problem you are trying to solve, so the above is somewhat generic advice for addressing your requirement to fill in a Last Month's Time field without understanding why you need the information or how it needs to be used. I think it is important to understand the root problem you are trying to solve by recording total time worked on an issue in the past month. If we know the root problem we might be able to give you better advice for achieving your goal.

Dmytro Danylov March 29, 2023

The goal is to be able to see per ticket:

  • number of total hours logged
  • hours logged last month
  • hours logged within current month
  • hours billed (this will be a custom input field I will add separately).

I was hoping to avoid going more complex route with REST API.

That's why tried using Automation as you are suggesting and was trying to figure out a way to retrieve the number of hours logged within a period.

I suspect what you are suggesting is to add/subtract to/from the field's value every time some worklog event takes place.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 30, 2023

I suspect what you are suggesting is to add/subtract to/from the field's value every time some worklog event takes place.

Yes, that is what I'm suggesting. 

I cannot think of a way to gather all the worklogs for an issue, figure out retroactively which ones are for last month and which for the current month, and sum the values by month, all in an Automation Rule.

Dmytro Danylov March 30, 2023

I see. So in this case it sounds like I will need three rules: one for worklog added, second for it being deleted, third for it being edited. Or there's a way to do it all in a single rule? 

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 30, 2023

The one Work Logged trigger works for all three.

Screen Shot 2023-03-30 at 10.51.01 AM.png

 

I haven't actually worked through all the details so I don't know for sure how or that it is possible to code the one rule to handle all the conditions of:

- work log created - would be adding time to total.

- work log updated - might have to determine if the work log time was reduced or increased.

- work log deleted - reducing the total time by the amount of time that was in the deleted work log.

Dmytro Danylov March 30, 2023

Ok, I will try to go down this path, thank you.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events