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

Automation - How to use variable inside Date plus function

CEDRIC DEVAUX July 16, 2024

Hello community,

 

I need your help, I want to automatically update due date when start date is postponed.

At ticket creation, Start Date & Due Date has been completed by user. 

When user postpones start date, I want to get difference of business days between the initial start and the new value then I add this difference to the due date

ex:  Initial start Date 2024-07-16, user changes to 2024-07-17

Difference days  =>  1day

Automation rule to update Due Date +1 Business Day

I create this rule but at calculation level,:

1. I create a customfield to get intial start before changing

{{fieldChange.from}}

2. I create a variable  "businessDaysToAdd "to calculate difference between initial start date to new start date

{{issue.customfield_10044.diff(issue.customfield_10861).businessDays.abs}}

3. Update due date with calculation with Date plus function

{{DueDate.plusBusinessDays(businessDaysToAdd)}}

 

It seems that a variable inside calculation  Date.plus function is not take into account.

Here my automation rule and my calculation.

Automation rules update duedate.png

Thank you in advance for your help ;)

1 answer

1 accepted

0 votes
Answer accepted
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.
July 16, 2024

Hi @CEDRIC DEVAUX 

Created variables are text, and to use them in a function requiring a number they must be converted by adding asNumber.  For example:

{{issue.someDateField.plusDays(varSomeVariable.asNumber)}}

Here are some other recommendations for the rule you show:

  • Perhaps write that created variable to the audit log to confirm it contains what you expect
  • I note you are using the absolute value function after the diff on business days.  Is that because you have the dates in the reversed order? 
    • This is relevant because the person who edited the field could make the start date earlier.  And so adding the days may not produce the results you expect.

Kind regards,
Bill

CEDRIC DEVAUX July 17, 2024

Hi @Bill Sheboy 

I was sure it was this type of subtlety but I couldn't find how to indicate that the result was a number.

Thank you it works !!!

I don't find documentation to talk about variables properties, I really appreciate if you have any pages on this subject :)

To answer to your questions:

  • Perhaps write that created variable to the audit log to confirm it contains what you expect
    • Previously I added a log to verify (and removed after my verification)  fwhat is the result of the difference betweeen old date and the new one but in the log you don't know what is the property (string or number) 
  • I note you are using the absolute value function after the diff on business days.  Is that because you have the dates in the reversed order? 
    • This is relevant because the person who edited the field could make the start date earlier.  And so adding the days may not produce the results you expect.
    • You're right, I change order of dates and now I able to move  start date after or earlier

 

To open the discussion, It's strange that timeline doesn't take into account this kind of case regarding business days when we move the start date date near of the weekend, the system will just move due date without taking into account the weekend whereas we are able to define business days and non working days.

In any case thanks a lot for your help Bill !

Kind regards,

Cedric

 

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.
July 17, 2024

Awesome; I am glad to learn that helps!

Regarding your other questions...

For documentation on Create Variable, this is all there is: https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Create-variable  And it does state the value is a string, but it does not suggest what to do when the value could be typed otherwise.

A workaround that sometimes helps is to use Create Lookup Table with a single row, as the values for those preserve the typing.  That may be for edge cases, as the table lookups may not fit all usage scenarios.

 

Regarding the timeline and adjustments, I do not have any suggestions for that.  You appear to be on Jira Premium, and so likely have Advanced Roadmaps versus Basic Timelines.  IMHO, neither really works like a purpose-built, project management tool, and so changing a single date in the middle of the chain needs to be handled other ways.

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