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,
BRFranzi
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?
It can be used as is (assuming you want "2 hours from now" as the value)
Hi David, thanks so much, that worked perfectly
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?
Hi @Franzi Joseph
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}
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.
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
It looks like you're new here. Sign in or register to get started.