Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Can not Copy Due date into Target End Field.



we have a Due Date Field in our Epics and Stories. People would like to work in the Portfolio and the Roadmaps there are only shown if u select a target start and target end. I created a function in Scriptrunner that copies the Date of the "Due Date" Field into the "Target End" Field. It works but it allways copies the date with -1. SO the Date is never correct. when i enter 30. as Due Date it copies 29. into Target End. Can anybody help me with this?

2 answers


Try something like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def indexManager = ComponentAccessor.getComponent(IssueIndexManager)
def issueService = ComponentAccessor.issueService

def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey('PT-1858')

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName('yourDateField');
customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), issue.getDueDate()),new DefaultIssueChangeHolder()); // update values

boolean wasIndexing = ImportUtils.isIndexIssues();

This Script upadates a value and Saves it, it doesnt copy the value from one date field to another tho

yes, updates the value of a date field with the previous value of another date field, isn't that copying a value?

Yes there is a "YourDateFild" where i can enter the source field, where can i enter the target field?

ModifiedValue(issue.getCustomFieldValue(customField), issue.getDueDate())

target field: issue.getCustomFieldValue(customField)

source field: issue.getDueDate()  

I allready found a solution but thx for your answer

So, what was the solution? Would be nice to actually hear

0 votes
Leo Community Leader Sep 23, 2019

hey @SebastianG_,

can you share your copy field script here to have a look 



I used the build in Script in Script Runner "Copie Value of Field so another Field"

Hi @SebastianG_ 

I tried to copy using same "Copie value of field" inbuilt script using script runner, but still the copied value is target date but its one day behind the actual date.

We are expecting you reply soon.

Thanks in advance.

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