Hi There! I'm trying to update my Expected Due Date field to be 3 business days from the Created Date. This is just a date field (not date/time). I want to exclude weekends (Saturday and Sunday) when calculating the Expected Due Date.
I do have access to ScriptRunner and JMWE to set up this post-function; I'm just unfamiliar with Groovy expressions. I'm using Jira Server v7.10.1.
Any advice would be greatly appreciated!
Hi Lauren,
Have a look at https://innovalog.atlassian.net/wiki/spaces/JMWE/pages/156073991/Add+a+certain+number+of+days+to+a+date+excluding+the+weekends
Create a JMWE Scripted Operation post function on your Create transition. Field will be Due Date, Value Type will be Groovy Expression, and Value will be that script, with the final line being date(new Date(),3)
Hope this helps,
Payne
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Payne ! I'm now trying to customize this a bit further. If a user inputs the ticket after 4:00 PM EST, I want to add an additional business day to the due date. I'm currently using the code provided in the link you sent over. Do you have any advice on how to customize?
Thanks, Lauren
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lauren,
So, what you want to do is send an argument of 4 days rather than 3 days if the current hour is 4pm or greater (16 on a 24-hour clock). So, here's one approach; change your final line where you call date(from,nod) to:
Calendar cal=Calendar.getInstance();
def hour = cal.get(Calendar.HOUR_OF_DAY)
def numDaysToAdd = 3 + (hour >= 16 ? 1 : 0)
date(new Date(),numDaysToAdd)
You may not recognize (hour >= 16 ? 1 : 0) ; that's using the ternary operator, which is a way to shortcut an if-then-else construct.
condition ? value if true : value if false
Hope this helps,
Payne
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.