• Community
  • Products
  • Jira Core
  • Questions
  • Hi, is it possible to set "Due Date" field value on "Create" transition using "Set Field Value to constant or Groovy expression Function" post function?

Hi, is it possible to set "Due Date" field value on "Create" transition using "Set Field Value to constant or Groovy expression Function" post function?

I am trying to set a value of "Due Date" field to some value (current date or current date + 5 days) using JMWE post function, but no results. Can anyone advise something on this matter? 

6 answers

1 accepted

It is indeed possible, but you need to look at the Java documentation for the Date class (your snippet above is incorrect). 

And you should see an error message in Atlassian-Jira.log right after displaying an issue that should show your calculated field. 

Finally, you can use Java Date methods to get the current date as well as to add to a date. 

Thanks, was able to implement.

Good!

Care to share your solution here?

This works in my case: due date (=current date) + 9 days.

import java.text.SimpleDateFormat;
import java.util.Date;
SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yy");
Date dt = new Date();
long time = dt.getTime()+9*24*60*60*1000;
String duedate = sdf.format(time);

duedate.jpg

pf.jpg

0 votes

Might be worth explaining

  • exactly what you have configured 
  • what the error is (if you get one on screen)
  • what the log file says when you create a new issue with the post-function
  1. I just want to know if such functionality is available in JMWE plugin. I was able to set value for "Original Estimate" field in the following way:Screenshot_1.jpg
    However, no luck with "Due date" field if I use for example: new Date(2016-05-01)

    Also, wondering if possible to get current date and set it for due date with some additional value.
     
  2. No errors
  3. Nothing, just record with error without any hint.

0 votes

It should be, but you'll need to tell us more about what you're trying.

We probably still need to see the error message.

Thank you for your replies.

Actually, something like: 

import org.apache.commons.lang3.time.DateUtils;
return DateUtils.addDays(new Date(), 9);

would be simpler.

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

676 views 4 16
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
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