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

Add + 1 day to Date field



in a workflow postfunction via scriptrunner i want to add + 1 day to my "Target end" Date field. Can anybody help me with a script, i also need one that workds with custom field IDs not Object Names. ty

1 answer

1 accepted

0 votes
Answer accepted

hello, if you want to simply add 1 day, place this one as the first postfunction in the list (or at least before the one that saves issue to db):

import com.atlassian.jira.component.ComponentAccessor

def customFieldObject = ComponentAccessor.customFieldManager.getCustomFieldObject(10101)
def dateValue = issue.getCustomFieldValue(customFieldObject)
dateValue += 1
issue.setCustomFieldValue(customFieldObject, dateValue)

just in case you want to skip weekends, here's a bit more complex version:

import com.atlassian.jira.component.ComponentAccessor

void addWorkDays(date, n) {
def i = 0
while (i < n) {
date.add(Calendar.DAY_OF_YEAR, 1)
if (!(date.get(Calendar.DAY_OF_WEEK) in [Calendar.SATURDAY, Calendar.SUNDAY])) {

def customFieldObject = ComponentAccessor.customFieldManager.getCustomFieldObject(11900)
def dateValue = issue.getCustomFieldValue(customFieldObject)
def calendarValue = Calendar.instance
addWorkDays(calendarValue, 1)
issue.setCustomFieldValue(customFieldObject, calendarValue.time.toTimestamp())


Thanks alot it worked as intended :)

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