Post function to update due date to 14 days in the future

I am attempting to set the due to 14 days in the future.  I am attempting to run the following as a sriptrunner post function but am getting no output.  Can anyone see anything wrong with this script?


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import java.sql.Timestamp;
int days = 14;
Calendar dueDate = Calendar.getInstance();

while (days > 0) {
dueDate.add(Calendar.DAY_OF_YEAR, 1)

/* Adjust for weekends > set to following Monday */
int dow = dueDate.get(Calendar.DAY_OF_WEEK);
if (dow == 7) {
dueDate.add(Calendar.DAY_OF_YEAR, 2)
} else if (dow == 1) {
dueDate.add(Calendar.DAY_OF_YEAR, 1)

issue.setDueDate(new Timestamp(dueDate.getTimeInMillis()));

1 answer

1 accepted

0 vote
Tarun Sapra Community Champion Aug 02, 2017

Well, the code looks fine, I can't seem to spot something odd in this code.  One thing that comes to my mind, is the post-function right at the top i.e. it should be the first post-function, if it's not the case can you please move it to the first position.

That is the case.  IT also states that it is not failing.  I have tested with the field being blank.  I have also tested with due date being populated.  If it is populated, the value is cleared.

I had other post functions that were causing problems.  Working fine now.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

165 views 0 4
Read article

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