Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add two date time custom fields using Jira Automation

venkatesh_rajput February 23, 2023

I am trying to have total duration after capturing deployment duration and testing duration using this kind of code

{{issue.customfield_27710.diff(now.minusHours(1)).plusMinutes(issue.customfield_27711.diff(now.minusHours(1)).minutes)}}

But this is not working for me can someone please guide me on this

1 answer

0 votes
Vamsi Kandala
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 23, 2023

Hi @venkatesh_rajput

Welcome to Atlassian community!

Are you getting any error?  Also, what data type were the custom fields 'customfield_27710' and 'customfield_27711'?

Did you try sending the values to log after splitting the above expression?  Like, try to send to log these values and see whether you are getting the desired result or error:

{{issue.customfield_27710.diff(now.minusHours(1))}}

{{issue.customfield_27711.diff(now.minusHours(1))}}

Thanks,
Vamsi

venkatesh_rajput February 23, 2023

Hi @Vamsi Kandala 

I am not getting any error but the values are not appearing it is appearing black, and the customfield_27710 and customefield_27711 are date time picker. Here these two customfields are getting values from other automation at the same time, here is the value for these two custom fields in other automation "{{now.minusHours(1)}}"

Here is the log for that.

Screenshot 2023-02-23 204202.png

Vamsi Kandala
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 23, 2023

Hi @venkatesh_rajput

Sorry, I am mistaken earlier.

The keyword 'plusMinutes' is used only for adding the required number of minutes to the given date time value and is not used for calculating the sum of the duration of two date fields.

I have tried this workaround and worked for me.

Create 3 custom fields which are of 'Number Field' data type, called 'Deployment_Duration', 'Testing_Duration' and 'Total_Duration'.

In the automation rule, use the 'Edit issue' action component and assign the following like:

Deployment_Duration = {{issue.customfield_27710.diff(now.minusHours(1)).minutes}}

Testing_Duration = {{issue.customfield_27711.diff(now.minusHours(1)).minutes}}

Total_Duration = {{customfield_xxxxx}} + {{customfield_yyyyy}}

Where 'customfield_xxxxx' is the custom field id for 'Deployment_Duration' and 'customfield_yyyyy' is the custom field id for 'Testing_Duration'

 Enclosed the screenshot here for your reference.

Hope this helps.

Thanks,
Vamsi

Screenshot 2023-02-23 123008.png

Like venkatesh_rajput likes this
venkatesh_rajput February 27, 2023

Hi @Vamsi Kandala

This worked for me, but I am facing an issue whenever the automation gets trigerred for this first time it is throwing error but it works fine for the same issue when its trigerred for the second time.

Suggest an answer

Log in or Sign up to answer