Forums

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

How to calculate the "Due date" based on the "Start date" + "Duration" (custom field)

Alanis_ Hans
Contributor
September 1, 2024

I created a number custom field called "Duration" that I want to use to calculate the Due Date, for example Due Date = Start date + Duration.

I created an automation but when I update the Start date, the value on the Due Date field disappears (if not empty) and the Automation Audit Log shows no errors and a status of success.

This is the Smart Value I am using:
{{issue.Start Date.plusBusinessDays(issue.Duration)}}

The fields that I am using are:
Start date
Duration
Due date

If I use the following Smart value, it works fine, and the Due Date field gets updated:
{{now.plusDays(7)}}


Any idea what's wrong?

2 answers

1 accepted

0 votes
Answer accepted
Jerrold - Empyra
Community Champion
September 1, 2024

Hi @Alanis_ Hans 

I was able to re-create the issue you are facing. The due date got empty when i edited the start date while there was no value in the duration field. so when there is no value in the duration field and then you edited the start date the due date value will be empty. can you please check the issue if there was value on the duration field. The smart value is not the issues it is working as expected. 

Thank you.

Alanis_ Hans
Contributor
September 2, 2024

Hello @Jerrold - Empyra 
Yes, both the Duration and the Start date fields have values. The Duration field is setup as a number field. 

Alanis_ Hans
Contributor
September 2, 2024

Here's a screenshot of the values on the Duration and Start date and the automation Edit part. I use "Duration" and the custom field ID and both options give me the same result.

01.jpg

 

02.jpg

Jerrold - Empyra
Community Champion
September 2, 2024

hi @Alanis_ Hans 

when i use the custom field id i am facing this issue but when i am using the name its working as expected so can you try one more time with the custom field name and still if its not working then can you try in the advance way. unselect the due date from the choose fields to set and click on more options and inside the additional fields insert this 

{
"fields": {
"duedate": "{{issue.Start Date.plusBusinessDays(issue.Duration)}}"
}
}

and update the rule and see whether its working 

Thank you.

Alanis_ Hans
Contributor
September 2, 2024

Hi again @Jerrold - Empyra 
First of all, thanks for your help.

I made the changes you suggested and now I am getting the following error message:

Error.jpg

 

And here's my rule:

Rule.jpg

 

I modified your query to see if that helped but I am getting the same error message:

{ "fields": {

     "duedate": "{{issue.Start Date.plusBusinessDays(issue.Duration).format("yyyy-MM-dd")}}"

}

}

Alanis_ Hans
Contributor
September 2, 2024

@Jerrold - Empyra It seems that the problem is with the Start Date field. I tried the following script and it works: 


{ "fields": {

     "duedate": "{{now.plusBusinessDays(3)}}"

     }

}

Jerrold - Empyra
Community Champion
September 3, 2024

Hi @Alanis_ Hans 

Can you Please try the below automation and share the audit logs. And Please make sure the "Duration" custom field ID is correct.

tc2.PNG tc3.PNG tc4.PNG  

Thank you.

Alanis_ Hans
Contributor
September 3, 2024

@Jerrold - Empyra  Same problem. The dueDate field gets empty and the Automation Audit Log shows no error:

4.png

Jerrold - Empyra
Community Champion
September 4, 2024

Hi @Alanis_ Hans 

I'm sorry that I couldn't pinpoint the exact root cause of the issue. It seems like there might be an error in pulling the start date data, leading to a null value when adding 3 days to it. Please check if there are any other custom fields named "start date." If you're using the default start date, try replacing it with its custom field ID, which is "10015" (this ID remains consistent across all cloud instances). You can use the following smart value in the edit action:

{{issue.customfield_10015.plusBusinessDays(issue.customfield_14335)}}

If You are still facing this issue please reach out to the Atlassian support team and they will look into it and help you on this regard you can raise a ticket from this link Atlassian support

Thank you.

Alanis_ Hans
Contributor
September 4, 2024

Thanks Jerrold.
I found the problem. The ID for my "Start date" field is 14207.
I used that on the Automation Script and it worked. 

Issue 5.jpg

Like • Jerrold - Empyra likes this
0 votes
Alanis_ Hans
Contributor
September 2, 2024

Hello @Jerrold - Empyra 
Yes, both the Duration and the Start date fields have values. The Duration field is setup as a number field. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events