Calculate Age via automations

Martin
Contributor
June 6, 2024

Good day!

I want an automation to write the amount of days since the creation of the issue and today.

I am using Jira Product Discovery. technically I will run the automation once a day and update the age field. 

I know now how to add days to a date, but I don't know how I could calculate the difference between.

 

I believe I need to use the {{createdIssue.created}} and now.jiraDate parameters.

Any idea?

I cannot use a marketplace app to do so.

1 answer

1 accepted

1 vote
Answer accepted
Duc Thang TRAN
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.
June 6, 2024

Hello @Martin 

I don't use Produc Discovery but in Jira Software, i using this smart value :{{issue.created.diff(now).days}}

Hope this can be use on JPD

Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 6, 2024

Hi @Martin ,

I'm prettyr sure you can't use the formula in the JPD field. But you can create a field called 'Age' and update this once a day via automatoin like @Duc Thang TRAN said.

I would recommend to only do this for issues that have not been resolved, so set a JQL on the scheduled trigger.

Cheers,

Rudy

Like Duc Thang TRAN likes this
Martin
Contributor
June 6, 2024

Hi guy,

this is a good trail. I ran it but the numbers were negatives, but accurate. I tweeked it to this:

 

{
"fields": {
"customfield_10842": "{{#=}}{{now.diff(issue.created).days}} * -1{{/}}"
}
}

 

Thank you all!

Duc Thang TRAN
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.
June 6, 2024

@Martin  
That's why I reversed the fields {{issue.created.diff(now).days}} to get a positive number of days. But your way works as well, and I'm glad it helped you.

Martin
Contributor
June 7, 2024

Ho! I didn't see that detail. I'll add this to my knowledge book.

Thank you @Duc Thang TRAN 

 

Do you have a reference on those expressions and variables?

Luqman Jamil
Contributor
July 11, 2024

Thank you @Duc Thang TRAN  it helped me. I am getting positive values now 

Luqman Jamil
Contributor
July 11, 2024

@Duc Thang TRAN  do you think this is good automation. this is how we have to set ? if this is wrong or over complexed. please can you give me the picture of the autmation? Automation.jpg

Duc Thang TRAN
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.
July 11, 2024

Hello @Martin 

Here you can find all smart value https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/

Hello @Luqman Jamil 

I think you can make it simpler.

In scheduled, you can use JQL and give status != done (uncheck "Only include issues that have changed since the last time this rule executed").

Then edit the issue field. You don't need a branch or field condition again because this is already filtered by JQL in the schedule.

 

Best :)

 

Luqman Jamil
Contributor
July 12, 2024

Thank you @Duc Thang TRAN  Now I am using the same thing which you guided me to set up automation, but I am getting the aging as 2 not 3. Do you know why? 

Automation1.jpg

 

The automation Rule is set up as bellow : 

When scheduled is using JQL Query as status != Done and Only include issues that have changed since the last time this rule executed is UNCHECKED. 

in the Edit Issue. using the Aging field and {{issue.created.diff(now).days}} 

Automation2.jpg

Duc Thang TRAN
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.
July 15, 2024

Hello @Luqman Jamil 

I think that with the configuration of Jira , Jira tries to round the result up, and automation rounds it down. If you want to see the real result, you can try this way 

{{#=}}{{issue.created.diff(now).hours}} / 24 {{/}}

Best :)

Suggest an answer

Log in or Sign up to answer