Hi,
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
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.ComponentAccessordef customFieldObject = ComponentAccessor.customFieldManager.getCustomFieldObject(10101)def dateValue = issue.getCustomFieldValue(customFieldObject)dateValue += 1issue.setCustomFieldValue(customFieldObject, dateValue)
just in case you want to skip weekends, here's a bit more complex version:
import com.atlassian.jira.component.ComponentAccessorvoid 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])) { i++ } }}def customFieldObject = ComponentAccessor.customFieldManager.getCustomFieldObject(11900)def dateValue = issue.getCustomFieldValue(customFieldObject)def calendarValue = Calendar.instancecalendarValue.setTime(dateValue)addWorkDays(calendarValue, 1)issue.setCustomFieldValue(customFieldObject, calendarValue.time.toTimestamp())
Thanks alot it worked as intended
How to do this in confiform
It looks like you're new here. Sign in or register to get started.