You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
need to write the script in the postfunction of the workflow to add the current date + 10 Days excluding the weekend
Please help me in exclude the weekends
eg : current date = 9th nov 4:12 +10 days means the result should show as
result = 23 nov 4:12 ( as weekend will fall on saturday and sunday)
Already written the script which is adding 10 days but including the weekends:
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def dateCf = customFieldManager.getCustomFieldObject("customfield_18761") issue.setCustomFieldValue(dateCf, new Timestamp((new Date() + 7).time))
return dateCf
I've written custom listener similar to your requirement quite long back(it's for 5 days)
this may give you some idea for start point
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.core.util.DateUtils
import java.util.Date.*
import java.text.SimpleDateFormat;
import java.text.DateFormat;
Issue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def baselineName = customFieldManager.getCustomFieldObjectByName("Base Date Field")
def baselineValue = issue.getCustomFieldValue(baselineName) as Date
DateFormat df = new SimpleDateFormat("dd/MMM/yyyy");
if(baselineValue != null)
{
Calendar baselineDate = GregorianCalendar.getInstance();
baselineDate.setTime(baselineValue);
int nod = 5
int weeks = (nod/5).intValue();
int remDays = nod%5;
baselineDate.add(Calendar.WEEK_OF_YEAR, weeks);
for(int i=1;i<=remDays;i++){
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
if (baselineDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
if (baselineDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
}
if (baselineDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
if (baselineDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
baselineDate.add(Calendar.DAY_OF_MONTH, 1);
baselineDate.clearTime()
//c1.getTime()
return baselineDate.getTime()
}
else {}
BR,
Leo