Add three days skipping weekends automatically to a Date Picker

Use case

Add three days to a date picker from another date picker field of your choice.

🛠️ Configuration

Add the post function Update fields to the transition of your choice.

Target issue*

Select current issue.

Fields

Field*

Choose a date field to be updated, e.g. Date picker, Planned end date, Planned start date or Due date.

Value*

Select Set field value manually (Jira expression) and enter the following expression after replacing "nnnnn" in "issue?.customfield_nnnnn" with the ID of the source date picker field.

Bash
startDate = issue?.customfield_nnnnn != null ? new Date(issue?.customfield_nnnnn + "T00:00:00Z") : null;
if(startDate == null){return null}
else {
	daysAdded = 3;
	startDateWeekday = startDate.getDay() == 0 ? 7 : startDate.getDay();
	weekendsSkipped = (daysAdded / 5) - (daysAdded / 5) % 1;
	endDate = startDate.plusDays(daysAdded + (weekendsSkipped*2));
	endDateWeekday = endDate.getDay() == 0 ? 7 : endDate.getDay();
		if(startDateWeekday == 6 && endDateWeekday == 6) {return endDate.minusDays(1)}
        else if(startDateWeekday == 7 && endDateWeekday == 7) {return endDate.minusDays(2)}
        else if(startDateWeekday == 6 && endDateWeekday == 7) {return endDate.plusDays(1)}
        else if(startDateWeekday == 7 && endDateWeekday == 6) {return endDate}
        else if(startDateWeekday == 6) {return endDate.plusDays(1)}
        else if(startDateWeekday == 7) {return endDate.plusDays(0)}
        else if(endDateWeekday == 6) {return endDate.plusDays(2)}
        else if(endDateWeekday == 7) {return endDate.plusDays(2)}
        else if(startDateWeekday < endDateWeekday) {return endDate}
        else if(startDateWeekday == endDateWeekday) {return endDate}
        else if(startDateWeekday > endDateWeekday) {return endDate.plusDays(2)}      
        else {return null}
}

 With minor modifications, you will be able to add a different number of days to any date skipping weekends by replacing the number 3 in the daysAdded variable with the desired number of days.

Use case Workflow function Parser functions
Set the due date based on the priority

Update fields

getMatchingValue()

Obtain the difference between two dates

Update fields


Assign an issue to the user who last commented on it

Update fields


Add three days skipping weekends automatically to a Date Picker

Update fields


Keep parent's priority in sync

Update fields


Set the assignee based on the issue type

Update fields

getMatchingValue()

Set the fix version to affects version when resolving an issue

Update fields


Use the app user to update non-editable fields

Update fields


Automatically add incident reporters to problem tickets

Update fields

append()

fieldValue()

linkedIssues()

toStringList()

Copy labels of a sub-task to the parent issue upon closing

Update fields


Assign an issue to the project lead, if the issue is unassigned on creation

Update fields


Add watchers from another field

Update fields

Transition issue

union()

toStringList()

Add a sub-task's summary and key to the description of its parent

Update fields


Set a date field to a future date

Update fields

dateTimeToString()

Record an auditable timestamp of a Compliance Approval

Update fields

dateTimeToString()

Copy field values from epic to issues under it after creation

Update fields Transition issue

epic()

issuesUnderEpic()

filterByStatus()

Set a date field to the current date

Update fields

dateTimeToString()

Assign important issues to the project lead

Update fields


Set the priority to Highest if the 'Infrastructure' component is selected

Update fields


Background priority calculation

Update fields

avg()