Skip to main content

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.

  1. Navigate back to the RentWork component.
  2. 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:

NamePackageTargetElementTypeTransactionTypeOutcomes
ValidateBookingcom.nsxrentWork::BookingStandardNoTransactioncarAvailable
ConfirmBookingcom.nsxrentWork::BookingStandardNoTransactionmessageSent

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.

  1. Navigate to Workflows and select BookingFlow.
  2. In the Transitions menu, edit the ValidateBooking and ConfirmBooking transitions.
  3. Populate the ExecuteTask field with the corresponding Task Element name.
  4. In the EndStates menu, add the successful TaskOutcome that we defined in the previous step.
NameExecuteTaskEndStates.Outcomes
ValidateBookingValidateBookingcarAvailable
ConfirmBookingConfirmBookingmessageSent

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.

  1. Navigate to the Transitions page for BookingFlow.

  2. Select the first transition, ValidateBooking.

  3. Click New Trigger in the menu and choose the onCreate option.

    The onCreate option makes sure that every time a new Booking record is created, the ValidateBooking task will automatically be initiated.

  4. Select the second transition, ConfirmBooking.

  5. Click New Trigger and choose the OnTransition option.

    onTransition will run a task immediately after a previous task (in this case, ValidateBooking) has successfully completed its state transition.


Congratulations!

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.