Create a New Business Event

Business event class

The name should include the noun or phrase that corresponds with the event, followed by the BusinessEvent suffix, such as CustomerInvoicePostedBusinessEvent.

First you will need to create the SalesInvoicePostedBusinessEvent class.

Extend the BusinessEventsBase class. Labels must be defined for the name and description arguments, but the at “@” symbol should be left out to avoid storing localized data. The BusinessEvents attribute provides the business events framework with information about the business event’s contract, name, and description.

After the class is created, use the following procedure to add methods to your class. The code examples define the SalesInvoicePostedBusinessEvent event.

  • Add a static newFrom<my_buffer> method, filling in the my_buffer piece with the table buffer that is used to initialize the business event contract.
  • Add private parm methods to maintain the internal state of the class.
  • Add the buildContract method. The method must be decorated with the Wrappable(true) and Replaceable(true) attributes, and it will only be called when a business event is enabled for a company.

Business events contract class

Use the following steps to extend the BusinessEventContract class and add methods to the class. The code examples define the SalesInvoicePostedBusinessEventContract event.

  • Extend the BusinessEventContract class, ensuring that it’s decorated with the DataContract attribute.
  • Add private variables to hold the contract state.
  • Add a private initialization method by using the initialize name. This method sets the business event contract class’s private state, based on data that is provided through the static constructor method.
  • Add a static constructor method.
  • Add parm methods to access the contract state. These methods should be decorated with the DataMember(”) and BusinessEventsDataMember(”) attributes. To populate the data contract’s internal state, you might need additional retrieval methods, which should be shown as private and called from the initialize method.