Forums

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

Automation rule question add x weeks to a date

Felix Köhn February 4, 2025

Dear all,

 

I'm trying to create an automation that sets a due date with a given start date and a duration.

 

When value changed for start date:

  • create smart value based on duration X
  • edit due date 
    • {{issue.customfield_<ID>.plusWeeks(<Smart_Value_X>))}

It gives an error "Failed to get value for..."


The customfield-ID is the ID of the start date.

 

 

If I set the duration field to 4 it shows that the Smart Value X is 4 in the automation log.

If I change the <Smart_Value_X> to a hard coded 4 in the automation it works aswell. 

I cant get him to use the smart value in this operation. 

I tried with a free text field and a number field for duration.

Start and due date are date fields.

 

Do you have a Suggestion?

5 answers

0 votes
Stefan Salzl
Community Champion
February 5, 2025

Hi @Felix Köhn 

Obviously the bug that variables can´t be used in calculation occurs in DC too.

If there is no urgent need to solve this via variable (as far as I understood the weeks are stored in a customfield of type numbers) I suggest to use the value directly in the calculation (similar to what @Florian Bonniec already mentioned)

 

some important points to mehtion regarding this solution:

I tested this in a DC and found out that values of numbers fields are stored/returned as float/with digit:

see my example- the field "Effort" is a customfield of type Number and filled with value "3"

so the following line:

weeks: {{issue.Effort}}

 

returns into:

weeks: 3.0

 

Therefore the calculation with only using the numbers value in .plusWeeks() failed too.

 

Nevertheless this can be solved with using the "floor" function to numbers. So the following line in the "Edit issue" action worked for me and the Due Date was updated correctly (replace the "Effort" with your specific customfield´s name):

{{issue.start Date.plusWeeks(issue.Effort.floor)}}

image.png

Please let me know if this helps.

Best
Stefan

 

0 votes
Felix Köhn February 5, 2025

Hi @Stefan Salzl

 

I saw your working suggestions in different posts and was wondering, if you have an idea or solution for this problem. 

 

Kind Regards

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.
February 4, 2025

Hi @Felix Köhn 

There is an intermittent defect for this symptom for Jira Cloud, where variables cannot be consistently used to increment date / time values...even when converted with asNumber.

 

I do not know if this defect also applies for Server / Data Center automation, but you could try two workarounds:

{{issue.customfield_12345.plusWeeks(varMyVariable.asNumber)}}

or

{{#issue.customfield_12345}}func=plusWeeks({{varMyVariable}}){{/}}

Assuming customfield_12345 is a date (or date / time) field and varMyVariable can convert to a number, both of these currently work for Jira Cloud.

 

Kind regards,
Bill

Felix Köhn February 5, 2025

hey @Bill Sheboy

 

 

thank you for your suggestion.

Unfortunately both options do not work in Data Center. 
In both cases the field is still empty. 

 

This is definitely a Bug in the Software.

 

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.
February 5, 2025

Thanks for confirming that.  At this point, I would work with your Jira Site Admin to submit this as a defect at the link below.  The earlier defect I noted is for Jira Cloud, and it will be good to let Atlassian know the scope of this problem.

https://support.atlassian.com/contact/#/

0 votes
Cristian0791
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 4, 2025

Hi Felix,

 

Hope you are doing well.

On the last step 

  • {{issue.customfield_XXXXX.plusWeeks(Duration)}}

try to use (Duration.asNumber) instead of (Duration)

Felix Köhn February 4, 2025

Hey Cristian,

 

thank you for the suggestion.

 

with {{issue.customfield_XXXXX.plusWeeks(Duration.asNumber)}} the field is still empty unfortunately.

 

 

I also did
And: Add value to the audit log 

and added the "End date" issue.customfield to see if it has any content. 

The field shows to be empty in the Automation Audit Log too.

 

 

Cristian0791
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 4, 2025

Hi Felix,

You can try the following.

Provide a value mannualy to Start date and see if the End Date is edited after.

Maybe is a problem beacuse Start date is empty.

Cristian0791
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 4, 2025

Also please make sure that: 

 

When: Value changes for

  • Start date / Duration
  • Create Issue; Edit Issue

Then: Create Variable

  • Variable Name: Duration
  • Smart Value {{issue.customfield_XXXXX}}  Here you have the customfield id for Duration

And: Edit Issue Fields

  • {{issue.customfield_XXXXX.plusWeeks(Duration)}} Here you have the custom field id for Start Date + variable
0 votes
Florian Bonniec
Community Champion
February 4, 2025

Hi @Felix Köhn 

 

Why do you need to use a variable ? Could you not use 

{{issue.customfield_<ID>.plusWeeks(4)}} 

 

Regards

Felix Köhn February 4, 2025

Hi @Florian Bonniec

 

because the duration is variable (not always 4) that can also change at a later date. 

If I create a work Package and i know the start date but not the end date, I can freely play around with the duration / start date and have it adjust automatically. 

 

Florian Bonniec
Community Champion
February 4, 2025

Can you share the automation configuration ? 

Felix Köhn February 4, 2025

When: Value changes for

  • Start date / Duration
  • Create Issue; Edit Issue

Then: Create Variable

  • Variable Name: Duration
  • Smart Value {{issue.customfield_XXXXX}}

And: Edit Issue Fields

  • {{issue.customfield_XXXXX.plusWeeks(Duration)}}

 

 

The Edit Issue Field is the End date

 

Unfortunately I cannot upload Screenshots.

I'd expect End date = start date + duration 
But the End date is empty

 

 

Florian Bonniec
Community Champion
February 4, 2025

If the duration is in a field could you use 

 

 

{{issue.customfield_XXXX.plusWeeks(issue.customfield_YYYY)}}

 

Where XXXX is the date field and YYYY the duration field ?

Felix Köhn February 5, 2025

Hi @Florian Bonniec

 

I tested this option and replaced the smart value with the issue.customfield Duration as suggested.

 

Unfortunately the End Date is still empty. 

 

This seems to be a bug as pointed out by Bill Sheboy

https://jira.atlassian.com/browse/AUTO-957

 

 

Florian Bonniec
Community Champion
February 5, 2025

Ya it's why I do not use variable in that case but I tested the propose smart value on my side and it works fine.

 

Is End Date a Date and Time or just Date Field ?

My Start date is a Date Field and End Date is in fact DueDate in my test. Duration was stored in a number field.

 

Felix Köhn February 5, 2025

Start and End Dates are both Date fields. 

DurationX is a Number field

I also created a second free text field for DurationY so i can test both.

 

Your working solution is implemented in a Cloud product or Data Center?
Do you mind sharing your working automation with me if its Data Center?

 

Kind Regards

Florian Bonniec
Community Champion
February 5, 2025

It's DC 9.12

 

{{issue.customfield_XXXX.plusWeeks(issue.customfield_YYYY)}}

 

XXXX is the Start Date field that is Date Picker

YYYY is a Number Field

I only use the trigger then the Edit Action.

 

Regards

Like Stefan Salzl likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.12.16
TAGS
AUG Leaders

Atlassian Community Events