Add an Object Event Handler

Using the process designer, you can create a new object event handler.

  1. Click Configuration on the navigation pane.
  2. Expand Site Configuration, then double-click Process Designer.
    The process designer opens on the content pane.
  3. Click New.
    The Server Process Object Event Handler editor opens.
  4. Enter a name for the object event handler in the Procedure Name field.
    Object event handler names must start with a letter, end with a letter or number, and contain only letters, numbers, and underscores.
  5. Click the folder icon next to the PHP Code File field and select a file to load.
    The Procedure Name field is then updated with the name of the file in the PHP Code File field, the State field displays Requires Save, and all PHP code displays as read-only in the PHP Content field.
    Tip: We recommend that you name your PHP code file according to its event function or manually update the Procedure Name field after loading the file.
  6. To execute the event handler asynchronously, select Execute Asynchronously. (This option is selected automatically if the PHP script includes the async keyword.)

    This option schedules the event handler to execute using a queuing system. If the first attempt fails for some reason, the event handler execution will be retried automatically up to nine times.

    • The initial three re-queuing are attempted with 3 minutes delay in between them. i.e., the first to third re-queuing occurs at 3 mins, 6 mins, and 9 mins.
    • The next three re-queuing are attempted with 20 minutes delay in between them. i.e., the fourth to sixth re-queuing occurs at 29 mins, 49 mins, and 69 mins.
    • The last three re-queuing are attempted with 3 hours, 12 hours, and 24 hours delay in between them. i.e., the seventh to ninth re-queuing occurs at 249 mins, 969 mins, and 2409 mins respectively.

    The time of execution of the event handler depends on the existing entries in the queue.

    You can use this option with an event handler that does not need to execute immediately and that is not required by the operation that triggered the event. For instance, if you have an integration that updates contact information in an external database when a contact is created in B2C Service, you can use an async event handler since the data can be sent any time.

    Note: You must select the Execute Asynchronously check box if you use cURL commands in your event handler. Do not select this option if you are adding an event handler for use in surveys or campaigns.
  7. Click Save.
    The status of the State field changes to Not Tested and the Test button is enabled.
  8. Click Test below the State field to test the PHP code file for errors and to verify the test harness.
    If no errors are encountered and your test harness validates, a message displays and asks if the object event handler test result was correct.
  9. Click Yes to acknowledge that the test ran as you expected.
    The message closes, the status of the State field changes from Not Tested to Tested, and the Test button is disabled.
  10. Click Save to save the process model.
  11. Associate the event handler with an object and event type that will trigger it.
    This step is not needed when creating event handlers to use in rules, surveys, or campaigns. See Triggers for Object Event Handlers.

What to do next

Before you can use the object event handler, the process model must be tested and deployed. See Deploy the Process Model and Roll Back the Process Model.