• Community
  • Questions
  • Updating due-date on workflow transition, with a custom field off set

Updating due-date on workflow transition, with a custom field off set


I have a challange, where a transaction, should change the due date of the issue. But the change is not static (+5 days, 1 month). the off set is based on a select custom field.

This field have have different periods (weekly, monthly, etc.)

Anyone know a way to solve this?

2 answers

1 accepted

Found that it could be done with a scripted post function, using Script Runner plugin

Hi Mikkel,

Did you manage to do it with script runner? Coud you post your script here?


import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import java.text.SimpleDateFormat
import com.atlassian.jira.issue.comments.CommentManager

Issue issue = issue
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager cfManager = componentManager.getCustomFieldManager()
CommentManager comManager= componentManager.getCommentManager()

String value = issue.getCustomFieldValue(cfManager.getCustomFieldObjectByName("Control Frequency"));
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd")
String originalDueDate = dateFormatter.format(issue.dueDate)

Calendar newDueDate = Calendar.getInstance()

boolean update = true

switch (value){
        case "Daily (weekdays)":

            newDueDate.add(Calendar.DAY_OF_YEAR, Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY ? 3 : 1)

        case "Weekly":
            newDueDate.add(Calendar.WEEK_OF_YEAR, 1)
        case "Every 4 years":
            newDueDate.add(Calendar.YEAR, 4)

        case "Every 5 years":
            newDueDate.add(Calendar.YEAR, 5)

            update = false

if (update){
    issue.dueDate.time = newDueDate.timeInMillis
    comManager.create(issue, "System", "Executed and Due date changed from " + originalDueDate + " to " + dateFormatter.format(issue.dueDate), false)



if(customfield_12345 == "1") {

dueDate = currentDate() + "5d";

} else {

dueDate = currentDate() + "4w";



Suggest an answer

Log in or Join to answer
Community showcase
Louis De Jaeger
Posted yesterday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

158 views 12 3
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot