Scenario: An employee uses an online form to request some vacation days. After the manager approves the request, the vacation days are automatically subtracted from the number of vacation days the employee has. These vacation days are stored in a company database.
Process: This process is created as a form start Workflow-type project.
The following screen shot shows the process:
A Dialog Workflow component begins the process by presenting the employee with a vacation request form.
The following screen shot shows the form:
There are two date picker components on this form that set the range of dates for the requested vacation. Each produces its own variable. The first date picker creates a variable called VacationStartDate, and the second creates a variable called VacationEndDate.
After the employee creates the request, a second Dialog Workflow component presents the request to a manager for approval.
If the manager approves the request, two components work together to subtract the number of requested days from the employee's total number of vacation days. These components are Date Difference and a custom component.
Date Difference compares the two date variables from the request form. It compares VacationStartDate with VacationEndDate and produces a variable called NumberOfDaysRequested.
The following screen shot shows the editor:
NumberOfDaysRequested is an integer variable that equals the number of days between the two dates. For example, if VacationEndDate equals 12/10/2009, and VacationStartDate equals 12/7/2009, NumberOfDaysRequested equals three.
After Date Difference has calculated the number of days requested, a custom component subtracts this number from the employee's total vacation days (as stored in a database).
Additional logic could be added to exclude weekends and holidays from the calculated total.