Let the platform do the work

Understanding Email Direction in Process Definitions

Overview

In Sugar, it is possible to create process definitions that target the Emails module. When doing so, it is highly valuable to trigger processes based on an email's direction (i.e. inbound or outbound). However, there are some special cases to be aware of around the four available values for the Direction field. This article outlines how each of the values should be evaluated and any considerations to keep in mind when designing process definitions targeting the Emails module.

Using Email Direction

There are four possible values for the Direction field on email records: Inbound, Outbound, Internal, and Unknown. It is important to know what each means and how it should be used when designing process definitions that target the Emails module. The following sections cover how to use each one.

Inbound

The Direction field is set to Inbound on email records that are created when a new email is received from an external source (e.g. a customer). To trigger a process on inbound emails only, select "New Records Only" in the Start event and add a Module Field Evaluation with the Direction field set to Inbound.
Inbound New

However, note that criteria on related records will not work on "New Records Only" Start events because the related record relationships have not yet been created. These relationships are established after the email record is created. As a result, criteria on related records can only safely be used in "First Update" and "All Updates" Start events.
Inbound Updated

Outbound and Internal

The Direction field is set to Outbound or Internal after an email in Sugar is sent. If sent to an external recipient (e.g. a customer), it is set to Outbound. If sent to another Sugar user, it is set to Internal. However, in either case, when the email record is initially created and still in a draft state, the Direction field is temporarily set to Unknown. In addition, related record relationships are not yet established at the time the email record is created. Therefore, to trigger a process on new outbound emails only or new internal emails only, you must use a "First Update" Start event and add a Module Field Evaluation with the Direction field set to Outbound or Internal respectively. This ensures that the process is triggered for emails with the correct Direction value and that any criteria on related records will work as expected.
Outbound Updated

Using "New Records Only" with the Outbound or Internal directions will result in processes not being triggered as expected. This is because newly created emails in Sugar will always have a direction of Unknown at the time of creation; the direction will be updated to Outbound or Internal when the email is sent.

Unknown

The Direction field is set to Unknown when a new email record is saved in a draft state. The Unknown direction is a temporary state and should not be used when evaluating the Direction field on emails. Processes may not be triggered as expected.