Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

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

automation for jira using smart value: plusDays using diff doesn't work

Eric Brandenburg August 13, 2024

Context, on a ticket, i have : 

  • an issue date field
  • a date automatically set when I transit a ticket into the blocked externally column

 

What I want to do : calculate the new issue date when the ticket comes back to the "in progress" column

 

For example : 

  • issue date = 15/08/2024
  • start of externally blocked = 09/08/2024 ("issue.customfield_10246")

On the 18/08/2024 I move back the ticket into the "In progress" column, the new issue date should then be 25/08/2024 (Now + (15/08 - 09/08) = 25/08)
You follow me ? 

I'm new to smart value and SQL function so I tried something exotic but it doesn't work : 

{{now.plusDays(duedate.diff(issue.customfield_10246.toDate).businessDays}}


Anyone figuring this out here ? 

Thanks you so much in advance

2 answers

1 accepted

0 votes
Answer accepted
Marc - Devoteam
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.
August 13, 2024

Hi @Eric Brandenburg 

Welcome to the community.

The diff smart value option is for calculation between date, the output will be a number no a date, as its a calculation.

toDate smart value option is only able to convert text information to a date, and that text needs to be in the correct format

So what could be done is that you:

  1. calculate the number of difference, store this in a field in Jira
  2. re-fetch the issue data
  3. then edit the issue date now plus the number of days in difference, it might be that you need to store the value form the number field in a variable before you can use it in the calculation
Eric Brandenburg August 14, 2024

Thanks to both of you, I got a "success" on that automation but the result is not the one expected.

My custom field is already a date fiel so it works fine as it is without the "toDate".

{{now.plusDays(issue.duedate.diff(issue.customfield_10246).businessDays)}}

which in calculation should look like that :

{{14/08.plusDays(issue.15/08.diff(issue.12/08).businessDays)}}


But the calculation went wrong : 
I had : 
due date = 15/08
start of blocked ticket = 12/08 (my customfield_10246)
So the result expected when putting the ticket back in the "in progress" column was due date = 17/08 but I got due date = 11/08 instead


Screenshot 2024-08-14 at 11.27.23.png

Marc - Devoteam
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.
August 14, 2024

Hi @Eric Brandenburg 

First try 

{{issue.duedate.diff(issue.customfield_10246).businessDays}}

 What is the outcome?

Eric Brandenburg August 14, 2024

Ok, I wanted to do it all in one formula but let's go step by step as you suggest, maybe easier.
So I created this automation rule : 

{{issue.customfield_10246.diff(now).businessDays}}

--> that works, success, and gives me the number of BusinessDays the ticket spent in the externally blocked column (customfield_10246)

Screenshot 2024-08-14 at 14.47.57.png

I then added a second rule (screenshot below) to add that number to the due date, it says success but I lost the value in the duedate field, it's now blank so it didn't work : 

{{duedate.plusBusinessDays(issue.customfield_10329)}}

 

Screenshot 2024-08-14 at 14.48.33.png

result on the ticket : 

Screenshot 2024-08-14 at 14.51.45.png

 

Any idea on this one ? This one should have been easy, no ? 

 

Like Marc - Devoteam likes this
Marc - Devoteam
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.
August 14, 2024

Hi @Eric Brandenburg 

Try, {{issue.duedate.plusBusinessDays(issue.customfield_10329)}}

Otherwise to create a variable that stores the number from the field "Nb de jours...."

lets call the variable {{days}}

{{issue.duedate.plusBusinessDays({{days}})}}

Like Eric Brandenburg likes this
Eric Brandenburg August 14, 2024

I didn't quite get the variable days thing but no need, adding "issue" works like a charm. Thanks a lot for your precious help on this one, really appreciate it ! 

 

Like Marc - Devoteam likes this
0 votes
Bill Sheboy
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.
August 13, 2024

Hi @Eric Brandenburg -- Welcome to the Atlassian Community!

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!

Until we see those...

 

Assuming your customfield_10246 is text, the expression you show is missing a closing parenthesis at the end:

{{now.plusDays(issue.duedate.diff(issue.customfield_10246.toDate).businessDays)}}

If instead your customfield_10246 is a date or date / time field, the toDate conversion may be removed:

{{now.plusDays(issue.duedate.diff(issue.customfield_10246).businessDays)}}

 

Kind regards,
Bill

Eric Brandenburg August 14, 2024

Thanks @Bill Sheboy and sorry for the missing screenshot. See my answer to marc below if you can help
Thanks again

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