Hi,
I want to use an Event-based Action to sum a number field.
More precisely:
The customfield_10238 is present in all subtasks of a story, and I want to display the sum in a field of the story (customfield_10231).
I found some conversations about this but I can't apply to my situation. Could any of you help me?
Thanks in advance
Hi @Estelle Decanis ,
it's actually not that easy. You can use an event-based action that listens to changes to the customfield_10238 field on issues of type sub-task. Then you can use a Set Issue Fields post-function on that action to set the parent issue's customfield_10231 to the sum of customfield_10238 on all sub-tasks. You have to select "Parent of the current sub-task" as the Target Issue(s), and for the value a script like:
{{ targetIssue | subtasks("customfield_10238") | sum("fields.customfield_10238") }}
However, this will only work if customfield_10238 is present on all sub-tasks, otherwise it'll return NaN.
Another difficulty is when you add or remove a sub-task. You also need to recalculate the parent issue's customfield_10231 value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Fischerone last question.
The customfield_10238 calculation should be triggered when there is a logtime entered. So I put the trigger on the update of the Time spent field.
Unfortunately this does not trigger the action. What is the error?
In the meantime I added Original estimate (and made a voluntary modification) to make it work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Because Jira doesn't trigger an event when that field is updated.
Have you tried listening to the Work Log Created event?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok, I understand better.
No I didn't try because the title of the subtasks is explicit and therefore they don't fill the work log
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I haven't thought about it, the work log is not necessarily the description of the logtime. Indeed as it creates a line it should work. But I have to create a similar action if the line is updated, and another one if the line is deleted.
Thank you very much for your information, it was very useful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David FischerI created new tickets and made a new test, but it does not work anymore.
The 1st logtime (7h) is displayed in the customfield_10238, but is not displayed in the Sum (customfield_10231) of the parent ticket. The Sum remains at 0.
I add a logtime (1h) on the same subtask, and the Sum displays 7, but not 8.
(Customfield_10238 and customfield_10231 are Number fields with the default value of 0). What is my mistake please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What's customfield_10238? In the previous screenshot you mentioned Time Spent and Orginal Estimate, so I'm a little confused...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry. I resume :
The customfield_10238 is filled with 3 actions :
the same with the trigger 'Work Log Updated'
the same with the trigger 'Work Log Deleted'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
and for the customfield_10231
I did this :
And the same with the trigger 'Work Log Updated'
and with the trigger 'Work Log Deleted'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since the second event-based action depends on the first one, you should use a different trigger. You should listen to changes to customfield_10238 instead of work log changes in the second action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes ! Thank you very much! Yes, that was my old setting and I didn't remember changing it.
Thanks again for your help David
So for the customfield_10231 :
The trigger 'Tempo (h)' is customfield_10238
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Fischer ,
I get this error :
Error message : Expected a Number but got: NaN
I don't understand. It's always the same number field. And from memory there was no change in the settings. What can cause the error ?
Regards,
Estelle
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Estelle Decanis ,
it might be happening when at least on sub-task doesn't have a value for that custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed the old issues did not take into account the change of parameter setting (set to 0 by default). Thanks for your help @David Fischer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for a completely different direction - is it a hard requirement for you to put your sub-task calculations into a field at the parent issue?
I'm asking because there's a number of apps in the Atlassian Marketplace that would perform such calculations "on the fly", based on a given set or hierarchy of issues. The advantage of such a solution is that it is often far more lightweight and flexible, as you don't need any kind of automation or scripting. The disadvantage is that you can't usually use the result in other Jira views or JQL.
If this is a direction that could work for you, I'd be more than happy to share how this works in the app that my team is working on, JXL for Jira.
Best,
Hannes | https://jxl.app
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your feedback @Hannes Obweger - JXL for Jira
On each subtask the collaborators enter time. And I have to display the total time of all these subtasks on the parent ticket. Indeed in a field, in order to show it in the dashboards.
There are certainly points to study on other issues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can accomplish this through automation (Note - This assumes your custom fields are numeric fields):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your help @Mark Segall . Indeed I had done the automation.
I want to take the time spent of the ticket, transform it in hour and make a sum in the parent ticket. It's easier to work directly with Event-based Action.
And with automation, the trigger corresponding to the update of the time spent does not work. So I would really prefer to use an event-based action
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Understood - I'll defer to other community members. Good luck
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.