It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Calculate date field based on due date in a linked issue

Hi all,

I would like to create a calculated date field with the misc custom field addon which does the following:

I have 1 Main Issue with a couple of subtasks. The calculated date fields are only relevant in the subtasks.

In the subtasks it is possible to set a dependency to another subtask, this is done via an issue link, link type: 'depends on' (e.g. subtask 1 can only be started after subtask 2 is finished). The calculated date should now calculate the date based on the due date of the linked subtasks + x days (the x days is the value which I have in another custom field).

Is that possible?

2 answers

Hi Dieter,

this is technically possible but the required script is a little complex. However, you should know something: the value of a calculated field is not stored in the database, but it is still stored in the JIRA index, which is used for searching as well as for the "List view". The index for an issue is updated only when that issue is transitioned or edited.  As a consequence, if you modify a linked subtask's due date, this will not update the primary subtask, so search won't work as expected.

However, when you display the main subtask, its calculated fields will be re-computed (although the results won't be stored in the index) so the calculated field will be accurate then.

So, before anyone tries to help you write the formula, you need to decide whether this limitation is acceptable for your use case.


Hi David,

thanks for the quick Response and the explanation. This limitation is acceptable for my use case.

Best regards


You can try with a formula derived from the following:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.user.ApplicationUser;

IssueLinkManager ilm = ComponentAccessor.getIssueLinkManager();
ApplicationUser curUser = ComponentAccessor.getJiraAuthenticationContext().getUser();
linkedIssues = ilm.getLinkCollection(issue, user, true).getOutwardIssues("Dependency");
if (linkedIssues.size()>0) {
    Issue dependsOn = linkedIssues.iterator().next();
    if (dependsOn.getDueDate()==null)
        return null;
    Long delta = issue.get("my field"); //assuming this is a Number field. Otherwise, needs to be converted to a Long
    Calendar dueDate = Calendar.getInstance();
    if (delta)
        dueDate.add(Calendar.DAY_OF_YEAR, delta);
    return dueDate.getTime();
} else
    return null;

You'll need to adapt it to your needs:

  • replace the link type name
  • possibly replace "getOutwardIssues" with "getInwardIssues" depending on the link direction you're interested in (just experiment until it works)
  • replace the field name that contains the number of days to add

For debugging, don't forget to watch atlassian-jira.log for errors. Also, you can use log.error("some text"); to write data to the logs for debugging purposes.


Thank you for the detailed answer! I will try that asap and will update you here if that worked for me.

Best regards


I found the time to test the script but even after some adjustments I could not get it to work. Im trying a different script now in a scripted field from the scriptrunner plugin. Nevertheless thank you for your help! 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

1,935 views 8 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you