How to calculate the "Due date" based on the "Start date" + "Duration" (custom field)
Asked by Alanis_ Hans:

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)}}

<br />

Any idea what's wrong?


Answers:
author: Jerrold - Empyra
body: Hi [@Alanis_ Hans](/t5/user/viewprofilepage/user-id/5454426)

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.

comments: author: Alanis_ Hans
body: Hello [@Jerrold - Empyra](https://community.atlassian.com/t5/user/viewprofilepage/user-id/5352480)   
Yes, both the Duration and the Start date fields have values. The Duration field is setup as a number field.


author: Alanis_ Hans
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/345126i7B68DE38C0A2EF98/image-size/large?v=v2&px=999 "01.jpg")

![02.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/345127i1D03C7AC4E7343A6/image-size/large?v=v2&px=999 "02.jpg")


author: Jerrold - Empyra
body: hi [@Alanis_ Hans](/t5/user/viewprofilepage/user-id/5454426)

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.


author: Alanis_ Hans
body: Hi again [@Jerrold - Empyra](/t5/user/viewprofilepage/user-id/5352480)   
First of all, thanks for your help.  

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

![Error.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/345160i1AE85EF54DFB3608/image-size/large?v=v2&px=999 "Error.jpg")

And here's my rule:  

![Rule.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/345161i8085B2FBEAC53682/image-size/large?v=v2&px=999 "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")}}"

}

}


author: Alanis_ Hans
body: [@Jerrold - Empyra](/t5/user/viewprofilepage/user-id/5352480) It seems that the problem is with the Start Date field. I tried the following script and it works:

<br />

{ "fields": {

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

}

}


author: Jerrold - Empyra
body: Hi [@Alanis_ Hans](/t5/user/viewprofilepage/user-id/5454426)

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](https://community.atlassian.com/t5/image/serverpage/image-id/345249i5CCB2AFC5F619AB3/image-size/large?v=v2&px=999 "tc2.PNG")![tc3.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/345250i78EF03E725E7EF7F/image-size/large?v=v2&px=999 "tc3.PNG")![tc4.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/345251iE2D404BF68DA8576/image-size/large?v=v2&px=999 "tc4.PNG")

Thank you.


author: Alanis_ Hans
body: [@Jerrold - Empyra](/t5/user/viewprofilepage/user-id/5352480) Same problem. The dueDate field gets empty and the Automation Audit Log shows no error:  

![4.png](https://community.atlassian.com/t5/image/serverpage/image-id/345415iA7CCB8B30DA310FE/image-size/large?v=v2&px=999 "4.png")


author: Jerrold - Empyra
body: Hi [@Alanis_ Hans](/t5/user/viewprofilepage/user-id/5454426)

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](https://support.atlassian.com/contact/#/)

Thank you.


author: Alanis_ Hans
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/345548iCE95072A5B48B99D/image-size/large?v=v2&px=999 "Issue 5.jpg")


author: Alanis_ Hans
body: Hello [@Jerrold - Empyra](/t5/user/viewprofilepage/user-id/5352480)   
Yes, both the Duration and the Start date fields have values. The Duration field is setup as a number field.


Tags: cloud

jira-work-management-cloud