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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Update End Date by Start Date and original Estimate Edited


I want to Update Custom end Date Field with this value:

end date = start date + original estimate


I think and check different methods and the last one is to use "Execute a ScriptRunner script" in Automation for Jira Plugin.  I use the server version of Jira:

Here my code, I'm new to groovy, Please help me to complete it:




import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import java.sql.Timestamp
import java.time.DayOfWeek
import java.text.SimpleDateFormat;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption

def myissue = issue as Issue

// Set the logging leve to DEBUG
import org.apache.log4j.Level

Issue issueKey = issue
def id=issueKey.getId()

// Get access to the Custom Field Manager
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

// Get the required custom field values
def StartDate = customFieldManager.getCustomFieldObjects(issue).find { == 'Start Date'}
def EndDate = customFieldManager.getCustomFieldObjects(issue).find { == 'End Date'}
def startDateVal = StartDate.getValue(issue)
def endDateVal = EndDate.getValue(issue)
def ost = issue.getOriginalEstimate()
def rst = issue.getEstimate()

def updated = myissue.getUpdated()

myissue.setCustomFieldValue(EndDate, new Timestamp(startDateVal-ost).Date)

2 answers

2 accepted

0 votes
Answer accepted

I found the answer:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueInputParameters
import org.apache.log4j.Logger
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue

def mylog = Logger.getLogger("com.onresolve.jira.groovy")

def userManager = ComponentAccessor.getUserManager()
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10403)
def issueManager = ComponentAccessor.getIssueManager()
def user = userManager.getUserByName("Jira Administrator")
def startdate = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10402");
def startdatevalue = issue.getCustomFieldValue(startdate) as Date
def oestimate = issue.getOriginalEstimate()/(3600*8) as int
def customFieldValue = startdatevalue + oestimate

def customFieldOldValue = issue.getCustomFieldValue(customField)
customField.updateValue(null, issue, new ModifiedValue(customFieldOldValue, customFieldValue), new DefaultIssueChangeHolder())


0 votes
Answer accepted
Swati Kahol Atlassian Team Oct 02, 2020

hey @Ansar Rezaei 

We have recently published a kb article to add Orginal estimate to a date field using Automation for Jira. Hope this helps :)


Andy M I'm New Here Feb 16, 2021

Hi Swati,

can you help with jira server how to implement same automation.


Suggest an answer

Log in or Sign up to answer

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