Workflow Events: To Create a New Event
This activity will walk you through the process of creating a custom workflow event and implementing a transition by using this event.
Learning Objectives
In this activity, you will learn how to do the following:
- Derive a value of a field and copy it to a custom field
- Explore the code of the predefined workflow to find where an event should be fired
- Create a custom event
- Fire a custom event in a graph extension
- 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 a repair work order should be assigned the Ready for Assignment status when the invoice created for the order is prepaid in the specified percent. For a repair work order to be prepaid, a user will first create an invoice for this order and then apply a prepayment to the invoice. If the percent of the applied prepayment is greater than or equal to the required prepayment percentage, which is specified on the Payments and Applications (AR302000) form, the system will change the status of the order from Pending Payment to Ready for Assignment to indicate that the prepayment is applied. You need to implement the needed changes for this system behavior.
Process Overview
To implement the needed state (status) change, in your extension library, you will define a new event and fire it when an invoice is prepaid. You will define the event handler, register it in the screen configuration for your custom workflow, and configure a transition.
System Preparation
In an instance with the T100 dataset, make sure that you have done the following:
- Prepared an instance with the PhoneRepairShop customization project and enabled the workflow validation by performing the prerequisite activities in the Preparing an Instance for Workflow Customization chapter.
- Prepared the screen configuration and defined the set of states by performing the prerequisite activities in the Preparing a Screen Configuration chapter.
- Implemented the
PendingPayment
andReadyForAssignment
states by performing the Workflow States: To Define a Workflow State prerequisite activity. - Implemented the
CreateInvoice
action by performing the Workflow Actions: To Configure the Conditional Appearance of the Action prerequisite activity.