Hello all,
I would like to set an automated due date/time within a post function of an issue. I already managed to set the "due date" custom field with the postfunction "Set field value of related issues (JMWE app)" where I said for example new Date() + 14 to set a due date 14 days after issue creation. But I could not manage to set the "due date/time" custom field to a due time of for example 2 hours after creation. How would this look like?
Thanks in advance,
BR
Franzi
Hi @Franzi Joseph ,
it's basically the same thing, except that to add hours you should use:
use (groovy.time.TimeCategory) {
return new Date() + 2.hours
}
I am not that deep into that script. Can I copy and past it like that or do I have to exchange this (groovy.time.TimeCategory) with something? Could you write it down so that i can just copy/paste it? :D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It can be used as is (assuming you want "2 hours from now" as the value)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is exactly what I was looking for, thank you @David Fischer
I wanted to change this to a year, so took a punt and changed 2.hours to 1.year and it worked a treat.
Thank you for sharing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Fischer ,
I have one additional question. Do you also have an idea how to exclude weekends here, so for example if I say
use (groovy.time.TimeCategory) {
return new Date() + 2.days
}
how can I make sure that Saturday and Sunday will not count here?
BR
Franzi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it's a little ugly, but you can do:
use (groovy.time.TimeCategory) {
def d = new Date() + 2.days
if (d.day == 6)
d = d + 1.days
if (d.day == 0)
d = d + 1.days
return d
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Fischer ,
I tried with setting due date five days from today and normally it should give me the 21st then but it still gives me the 19th, which means it is counting the weekends. So looks like it doesn't work.
BR
Franzi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Right, it only works for adding 2 days, as in your example.
Try this instead:
def d = new Date()
for(i=0; i < 5; i++){
d = d + 1
if (d.day == 6)
d = d + 1
if (d.day == 0)
d = d + 1
}
return d
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.