You can create and manage time and holiday schedules by
using the JavaScript API. You can set time and holiday schedules for
both processes and activities. After you add a new time or holiday
schedule, it immediately becomes available in the time or holiday
schedule list in the authoring environment.
About this task
Avoid removing the default holiday or time schedules. The
default schedules are specified in the
99Local.xml configuration
file. Changes to the default schedules require changes to the
100Custom.xml file.
Procedure
- Create an integration service by using a server script. The following example script creates a service that dynamically
sets the holiday and time schedule for a process and stores the schedules
in the TWHolidaySchedule and TWTimeSchedule variables.
To view the variable parameters that you can use, open the variables
from the System Data toolkit.
var holidaySchedule = new tw.object.TWHolidaySchedule();
holidaySchedule.name = "myHolidaySchedule";
holidaySchedule.dates = new tw.object.listOf.Date();
holidaySchedule.dates[0] = new tw.object.Date();
holidaySchedule.dates[0].parse("20170101", "yyyyMMdd");
holidaySchedule.dates[1] = new tw.object.Date();
holidaySchedule.dates[1].parse("20170116", "yyyyMMdd");
holidaySchedule.dates[2] = new tw.object.Date();
holidaySchedule.dates[2].parse("20170529", "yyyyMMdd");
holidaySchedule.dates[3] = new tw.object.Date();
holidaySchedule.dates[3].parse("20170704", "yyyyMMdd");
holidaySchedule.dates[4] = new tw.object.Date();
holidaySchedule.dates[4].parse("20170904", "yyyyMMdd");
holidaySchedule.dates[5] = new tw.object.Date();
holidaySchedule.dates[5].parse("20171231", "yyyyMMdd");
tw.system.addHolidaySchedule(holidaySchedule);
var timeSchedule = new tw.object.TWTimeSchedule();
timeSchedule.name = "myTimeSchedule";
timeSchedule.excludeHolidays = false;
timeSchedule.periods = new tw.object.listOf.TWTimePeriod();
var timePeriod = new tw.object.TWTimePeriod();
timePeriod.startTime = new tw.object.Time();
timePeriod.startTime.parse("09:00", "HH:mm");
timePeriod.endTime = new tw.object.Time();
timePeriod.endTime.parse("17:00", "HH:mm");
timePeriod.monday = true;
timePeriod.tuesday = true;
timePeriod.wednesday = true;
timePeriod.thursday = true;
timePeriod.friday = true;
timePeriod.saturday = false;
timePeriod.sunday = false;
timeSchedule.periods[0] = timePeriod;
tw.system.addTimeSchedule(timeSchedule);
- Save and run the integration service.
Note: It
might take some time for the new schedules to be available in Process Designer after
running the integration service. To make use of your new schedules
right away, restart Process Designer before
you begin modeling.
- Create a process, and add an activity with a default service.
- Link the activity in a start-end flow.
- On the Implementation tab of the
activity or the Overview tab of the process,
select the holiday schedule and the time schedule that you created.
- Save the process.
- Run the process, and then open the Process Inspector tab
to verify the due date calculation.