Jira automation web request, calculate hours for each issue

Pasi Pönkkö February 7, 2025

I get webresponse which returns all the issues under parent issue. I need to calculate and update each issues hours to field "reported hours". The problem is that my update issue field event calculates sum of each issue which starts with the same number. For example if I have issues like P1234-1 and P1234-11 I get the sum of these issues but what I actually want is that every ticket gets only the hours for exact match. 

Here I have an example and what I want is that P1234-1 gets 4 hours and P1234-11 gets 2 hours.

What I get now is 6 hour for issue P1234-2.

 

 {
        "personId": "12345",
        "timeEntry": {
            "description": "P1234-1: Doing something",
        },
        "time": {
            "date": "2024-12-09T00:00:00.000",
            "hours": 1
        }
    },

 

 {
        "personId": "12345",
        "timeEntry": {
            "description": "P1234-11: Doing something else",
        },
        "time": {
            "date": "2024-11-09T00:00:00.000",
            "hours": 2
        }
    },

 

 {
        "personId": "12345",
        "timeEntry": {
            "description": "P1234-1: Doing something",
        },
        "time": {
            "date": "2024-10-09T00:00:00.000",
            "hours": 3
        }
    },

1 answer

0 votes
Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 7, 2025

@Pasi Pönkkö 

can you share screen shot of the automation developed so far?

Also, share the end point url that you are using

Once we know the details then community will be able to help address your use case better.

Pasi Pönkkö February 7, 2025

I tried to add compare two values but that didn't seem to make any difference at all.

 

1.pngScreenshot 2025-02-07 144911.png

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 7, 2025

@Pasi Pönkkö 

For isssuetype = Task, there is a field under timetracking i.e. timeSpentSeconds.

As an alternative approach, after your JQL, you get each task.

Can you use combination of branch for children and lookupissues + edit field to see if this serves your purpose? 

Pasi Pönkkö February 10, 2025

How to create lookupissues to get web requests data so that I can sum all the hours for each issue I get in web response.

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2025

@Pasi Pönkkö 

i am not clear why you are using webhook. 

 

see if you create a rule like this, does that serve your purpose?

snip.png

Pasi Pönkkö February 10, 2025

The reason I'm using webhook is that I'm fetching the reported hours from our ERP and I want to show them for each issue in JIRA. At the moment our ERP system is the only valid place to check the hours.

So what I need is something like:

1) get the issue key from epic and get the reported hours from ERP for all the child issues

2) go through the data webhook sends me. I need the sum of hours for each ticket.

3) update the reported hours for each issue

 

So the problem at hand is that I get the list from ERP but there are many values for many tickets and I need to sum the hours for each issue.

All the issue keys are looked from the description field: 

 "description": "P1234-1: Doing something"

 

And the Jira automation seems to lack necessary functions to get specific key out of this field.

 

so...For example if I have issues like P1234-1 and P1234-11, I get the sum of these issues but what I actually want, is that every ticket gets only the hours for exact match. 

 

Pasi Pönkkö February 10, 2025

jiraaaaaaaa.png

This approach works with postman but not in Jira.

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2025

@Pasi Pönkkö 

While branching, instead of using Children, use Advanced branching and set it like this

 

snip.png

 

Now you have access to individual items. If your response is JSON, then you can use dot notation. if it is a string then you will need to compare based on the string condition you were trying above.

 

Would be interested to know if this helps you move forward.

 

Pasi Pönkkö February 10, 2025

I managed to get rex ex working in jira too. I had to add %20 characters around which Postman seemed to do this on it's own.

contains(timeEntry/description,'{{issue.key}}')%20and%20not%20contains(timeEntry/description,'{{issue.key}}[0-9]')&onWorkflow=true&noWorkflow=true

 

So I got this to work now. Thanks.

 

jira2.png

Suggest an answer

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

Atlassian Community Events