Workflow Events: To Use an Existing Event

The following activity will walk you through the process of creating a custom event handler for an existing event and implementing a transition that is triggered by this event.

Learning Objectives

In this activity, you will learn how to do the following:

  • Explore the code of the predefined workflow to find the event
  • Create a custom event handler
  • Bind the event handler to an event
  • Register an event handler in a particular state
  • Create a transition triggered by an event
  • Override the Persist method to save changes in a custom entity

Story

Suppose that on the Repair Work Orders (RS301000) form, a repair work order should be assigned the Paid status when the invoice created for the order is fully paid—that is, when the invoice is assigned the Closed status. You need to implement the needed changes for this system behavior.

Process Overview

To change the state of the repair work order from Completed to Paid, you will use an existing event that is fired when the invoice document is assigned the Closed state. First, you will explore the code of the Invoices (SO303000) form to find the event that is fired. Then, in your extension library, you will create a custom event handler for this event, bind it to the workflow on the Repair Work Orders (RS301000) form, and implement the transition. You will also implement the Paid state and override the Persist method on the Invoices form.

System Preparation

In an instance with the T100 dataset, make sure that you have done the following: