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?

abstractelement July 3, 2016

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

2 votes
Answer accepted
David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2016

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. 

abstractelement July 7, 2016

Thanks, was able to implement.

David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

Good!

Care to share your solution here?

abstractelement July 7, 2016

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

Suresh Bhandiwad March 8, 2018

@abstractelement, Could you please help to modify above script to work only for due date. That is Due Date should be set as on when transition is made. I tried modifying the below line in above script but it didn't work.

long time = dt.getTime();

 Thanks,

abstractelement March 9, 2018

Do you use JMWE plugin or some another plugin? What is the date pattern for your JIRA instance? What have you configured in details?

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2018

Hi Suresh, I'm not sure I understood what you're trying to do. Are you trying to set the Due Date field to "now"? If so, just use the following script:

new Date()
Suresh Bhandiwad March 9, 2018

Hi David,

Thank you for your quick response.

Yes, your understanding is correct. I want to set Due Date to "now".  Could you please provide the complete script David. 

Yes, we do have a JMWE plugin where I have configured start date. However, Due Date isn't mentioned in the drop down list. So, need help with the script to implement the same. Due Date should choose the system date on when this transition is done.

Date format: dd/MMM/yy

Thanks in advance.

Suresh Bhandiwad March 9, 2018

Hi David,

Thank you for your quick response.

Yes, your understanding is correct. I want to set Due Date to "now".  Could you please provide the complete script David.

Yes, we do have a JMWE plugin where I have configured start date. However, Due Date isn't mentioned in the drop down list. So, need help with the script to implement the same. Due Date should choose the system date on when this transition is done.

Date format: dd/MMM/yy

Thanks in advance.

Suresh Bhandiwad March 9, 2018

Hi David,

Thank you for your quick response.

Yes, your understanding is correct. I want to set Due Date to "now". Could you please provide the complete script David.

Yes, we do have a JMWE plugin where I have configured start date. However, Due Date isn't mentioned in the drop down list. So, need help with the script to implement the same. Due Date should choose the system date on when this transition is done.

Date format: dd/MMM/yy

Thanks in advance.

Suresh Bhandiwad March 9, 2018

Hi David,

Thank you for your quick response.

Yes, your understanding is correct. I want to set Due Date to "now". Could you please provide the complete script David.

Yes, we do have a JMWE plugin where I have configured start date. However, Due Date isn't mentioned in the drop down list. So, need help with the script to implement the same. Due Date should choose the system date on when this transition is done.

Date format: dd/MMM/yy

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2018

I don't understand by what you mean by "we do have a JMWE plugin where I have configured start date".

Anyway, in the "Set Field Value (JMWE add-on)" post-function, the Due Date field should appear in the list of fields. And all you need is to set the value to the following Groovy expression:

new Date()

Which version of JMWE and Jira are you using?

Suresh Bhandiwad March 9, 2018

David, Sorry there was a mix up here.. My answers were for you and @abstractelement.

We can implement Start date field to pick transition date through JMWE plugin in Jira, however for Due Date it's not possible. Hence, other way is to do this using script-post function offered by Adaptavist Script runner. 

David: I am clear with your answer now, I'll check and confirm the same.

Fyi.. Jira - 7.6.3 and JMWE: 5.1.1

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2018

I don't understand why it's not possible for Due Date...

Also, you can also create a Scripted (Groovy) post-function using JMWE...

Suresh Bhandiwad March 9, 2018

Thanks David for quick response. There is no Due Date in the drop down list, when tried to implement the same way as when using Start Date(used "Update Issue Custom Field (JSU)". This is offered by Suite Utilities for Jira (JSU). Sorry for creating confusion. 

Thanks a lot. I'll test the way you have advised.

0 votes
David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2016

Actually, something like: 

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

would be simpler.

0 votes
abstractelement July 7, 2016

Thank you for your replies.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2016

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.

0 votes
abstractelement July 4, 2016
  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
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 3, 2016

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events