Defining task elements
In the previous section, we defined transitions to execute our business process. (e.g. going from state BookingToBeValidated to BookingConfirmed). During such a transition, a certain business rule or business logic will be applied. This part will be modelled as a Task Element. A Task Element contains the actual technical implementation required to fulfill a business step. For instance, this could be the Java code that checks if a car is already booked on a given date.
We will now define the tasks for the two transitions we defined in the previous section.
- Navigate back to the RentWork component.
- Select New TaskElement from the component menu.
For each task, we must specify the TargetElement (the Data Element the task operates on) and one or more Outcomes (the possible results of the execution).
Create the following two Task Elements:
| Name | Package | TargetElement | Type | TransactionType | Outcomes |
|---|---|---|---|---|---|
| ValidateBooking | com.nsx | rentWork::Booking | Standard | NoTransaction | carAvailable |
| ConfirmBooking | com.nsx | rentWork::Booking | Standard | NoTransaction | messageSent |
In the case of ValidateBooking, we check if a car is available, so the successful result is defined by the Outcome
carAvailable.
The Task name and Transition name are the same here, but note that the same Task could be re-used by multiple
Transitions if the business logic were identical.
Linking tasks to transitions and defining triggers
We must now link these newly created Tasks to our Transitions and define Triggers to specify when the process should start.
Step 1: Link tasks and outcomes to transitions
- Navigate to Workflows and select
BookingFlow. - In the Transitions menu, edit the
ValidateBookingandConfirmBookingtransitions. - Populate the
ExecuteTaskfield with the corresponding Task Element name. - In the
EndStatesmenu, add the successful TaskOutcome that we defined in the previous step.
| Name | ExecuteTask | EndStates.Outcomes |
|---|---|---|
| ValidateBooking | ValidateBooking | carAvailable |
| ConfirmBooking | ConfirmBooking | messageSent |
Step 2: Define triggers
As a last step, we must define a Trigger to specify the event that causes a workflow to begin or advance. Just as in any business process modeling tool, this trigger is typically defined as an action (e.g., a new booking being created) or a specified time period.
-
Navigate to the Transitions page for
BookingFlow. -
Select the first transition,
ValidateBooking. -
Click New Trigger in the menu and choose the onCreate option.
The
onCreateoption makes sure that every time a new Booking record is created, theValidateBookingtask will automatically be initiated. -
Select the second transition,
ConfirmBooking. -
Click New Trigger and choose the OnTransition option.
onTransitionwill run a task immediately after a previous task (in this case,ValidateBooking) has successfully completed its state transition.
You have now successfully implemented your first business process in the NS application, utilizing Data Elements, Workflow Elements, Task Elements, and Triggers to model the required functionality.