How to add 2 business days in workflow timer activity

Santhosh23
Tera Expert

How to add 2 business days in workflow timer activity

1 REPLY 1

Yashsvi
Kilo Sage

Hi @Santhosh23,

follow this step to achieve 2 business days in workflow timer activity:

 

1. Start Date: Determine the starting date from which you want to add 2 business days.

2. Script Action: Create a script action in your workflow with JavaScript to calculate the target date:

var start = new GlideDateTime(); // Replace with your actual start date
var target = new GlideDateTime(start);

var businessDaysToAdd = 2;
var count = 0;

while (count < businessDaysToAdd) {
target.addDays(1);
// Check if the day is a business day (Monday to Friday)
if (target.getDayOfWeek() != 1 && target.getDayOfWeek() != 7) {
count++;
}
}

gs.info("Target Date: " + target.getDisplayValue()); // Output the target date

3. Adjust for Holidays: If needed, adjust the script to skip holidays by checking against a holiday calendar.

4. Testing: Test the workflow thoroughly to ensure the calculated target date aligns with your expectations, especially around weekends and holidays.

5. Implementation: Integrate this script action into your workflow timer activity to trigger the calculation based on your workflow conditions.

This script calculates the target date by skipping weekends (Saturday and Sunday). Modify it as necessary to fit your organization's specific business rules regarding business days and holidays.

 

Thank you, please make helpful if you accept the solution.