Skip to main content

System events

System events are identifiable system actions, such as the creation of a document, the status change of a document, and the completion of a workflow. You can create custom system events and configure notifications for them.

System events are processed by transaction, and information is synthesized when multiple actions occur in the context of a single transaction. For example, when a workflow starts, the document state may change and document roles may be assigned. These items are rolled into a single notification when necessary.

Create custom system events

Warning

System event handlers (any Apex class that implements the SE_ISystemEventHandler or SE_ISystemEventHandlerWithGetters Apex interfaces) do not support the use of data manipulation language (DML) when processing a system event.

To create a custom system event:

  1. Create a System Event (mvn__SE_System_Event__mdt) metadata record. Key fields include:

    • System Event Name - enter a unique API name for the record.

    • Payload Apex Class Name - specify the payload type for the system event. If your custom system event uses a list of SObjects as the payload, leave this field blank. If the system event uses a list of custom Apex class objects as the payload, enter the API name of a custom Apex class. The custom Apex class must implement the SE_ISystemEventApexClassPayload interface:

      global interface SE_ISystemEventApexClassPayload {
          String getUniqueId();
      }
      Example 1. Payload
      /** Custom class that implements the SE_ISystemEventApexClassPayload interface */
          public class MyCustomPayload implements SE_ISystemEventApexClassPayload {    
          /** Private variable to store this instance's unique Id */    
          private String uniqueId;    
          
          /** Constructor that initializes the instance with an unique Id */    
          public MyCustomPayload() {    
          this.uniqueId = UUIDGenerator.generateId();    
          }    
          
          /** Implementation of the SE_ISystemEventApexClassPayload interface method that returns the unique Id */    
          public String getUniqueId() {    
          return this.uniqueId;    
          }
      }


    • Payload Apex Class Namespace - enter the namespace of the Apex class defined in the Payload Apex Class Name field.

    • Priority - enter the order in which the custom system event should be processed. A system event with a priority of 1 is processed before a system event with a priority of 2.

    For a list of all the System Event fields, visit the System Event custom metadata type.

  2. Create a System Event Configuration (mvn__SE_System_Event_Configuration__mdt) metadata record record. Key fields include:

    • System Event - associate the System Event metadata record that you created in step 1.

    • Handler Name - enter the API name of the Apex class that implements the associated System Event metadata record. The custom Apex class must implement the SE_ISystemEventHandler interface:

      /**
       * @author       Komodo Health
       * @description  Interface for the System Events handlers
       */
      global interface SE_ISystemEventHandler {
          /**
           * Processes the SE_System_Event_Configuration__mdt records for the given new and old objects.
           *
           * The input variables are generic so that any type of payload in the form of an Object/SObject can be passed,
           * the implementation is responsible for casting them to the appropriate type to be able to process them.
           *
           * @param  config         the SE_System_Event_Configuration__mdt being processed
           * @param  newRecords     the list of new/updated payload Objects
           * @param  oldRecordsMap  the map of old SObject records sorted by Id when the routers processes SObjects
           */
          void process(SE_System_Event_Configuration__mdt config, List<Object> newRecords, Map<Id, SObject> oldRecordsMap);
      }

      In addition to implementing the SE_ISystemEventHandler interface, the handler can optionally implement the SE_ISystemEventHandlerWithGetters interface. This interface allows the handler to create emails, Salesforce notifications, Chatter posts, and audit logs.

      /**
       * @author      Komodo Health
       * @description Interface for the System Event handlers that also implement getters for notification, chatter posts
       *              and/or SObjects
       */
      global interface SE_ISystemEventHandlerWithGetters extends SE_ISystemEventHandler {
          /**
           * @return   the List of generated SE_SalesforceNotification records that represent the custom notifications
           */
          List<SE_SalesforceNotification> getSalesforceNotifications();
      
          /**
           * @return   the List of generated SE_EmailMessage that represent the emails
           */
          List<SE_EmailMessage> getEmailMessages();
      
          /**
           * @return   the List of generated SE_ChatterFeedPost that represent the chatter posts
           */
          List<SE_ChatterFeedPost> getChatterFeedPosts();
      
          /**
           * @return   the List of generated generic SObject records to insert (e.g. document audit log entries)
           */
          List<SObject> getSObjects();
      }

    For a list of all the System Event Configuration fields, visit the System Event Configuration custom metadata type.

Notification channels

When a document system event occurs, notifications are sent to the configured channels for that system event. Channels include email, Salesforce notification, Chatter, and audit log. You can disable notifications for all system events in your Salesforce instance.

Email and Salesforce notifications

You can receive emails and/or Salesforce notifications when document system events occur. Salesforce notifications are alerts that display in the user interface when you click the NotificationNotification icon icon.

To define the types of notifications that users in specific roles receive when specific system events occur, create and modify records for these custom metadata objects:

  • Document Notification Audience (mvn__CM_Document_Notification_Audience__mdt) - defines target audiences for system event notifications. Target audience can be based on a Document Role, Group, Salesforce user ID, or user query filter. For more information, visit Document Notification Audience.

  • Document System Event Notification (mvn__CM_Document_System_Event_Notification__mdt) - manages how system event notifications are sent to users via Salesforce notifications and emails. For more information, visit Document System Event Notification.

To configure the button colors in the emails, reference the Configure email button colors section below.

To use custom labels to modify the text in system event notifications, reference the Configure notification body section below.

Chatter feed

A document's Chatter feed lists the system events that were fired in relation to that document. To specify which system events should create Chatter feed notification, modify the Create Document Chatter Post (mvn__CM_Create_Document_Chatter_Post__c) field for the appropriate System Event mvn__SE_System_Event__mdt) custom metadata records.

When users follow documents, the documents' feeds display in the user’s aggregate Chatter feed.

Audit log

The audit log for a document lists the system events that were fired in relation to the document. To specify which system events should create an audit log entry, modify the Create Document Audit Log (mvn__CM_Create_Document_Audit_Log__c) field for the appropriate System Event mvn__SE_System_Event__mdt) custom metadata records:

To view the audit log for a document in the user interface, use the MCM - Document Activity (cmDocumentActivity) component. The component's Audit Log History tab displays the document record's system event history. A maximum of 500 entries display. If you need to see more than the last 500 entries, use Salesforce's Query REST API.

Note

Audit log details for a Document State Change system event are restricted to the old status value and the new status value for the document.

Audit Log History for a document

Configure email button colors

The workflow buttons in the email notifications have a purple (#3a225d) background fill and a white (#ffffff) text color by default. You can configure the colors in the following email templates to match your organization's branding:

  • Password reset email

  • Portal welcome email

  • Workflow emails

To configure the colors:

  1. Navigate to the System Event Setting (mvn__SE_System_Event_Setting__mdt) custom metadata type.

  2. Click the Default (PP_Default) metadata record.

  3. On the Email Call To Action Button Color (mvn__SE_Email_Call_To_Action_Button_Color__c) field, enter the hex code for the color you wish to set as the button's background fill.

  4. On the Email Call To Action Text Color (mvn__SE_Email_Call_To_Action_Text_Color__c) field, enter the hex code for the color you wish to set for the button's text.

  5. Click Save.

Configure notification body

If the out-of-the-box system event handlers build your system event notifications, you can use custom labels to modify the text in your notifications.

To modify the text in system event notifications:

  1. Open the relevant custom label in Edit mode. The custom label names for system event notifications follow this naming convention: <System Event Name>_<notification location>. Notification locations include:

    • Email_Body

    • Feed_Body

    • Notification_Body

    For example, the custom label that defines the email body for the Document New Version system event notification is CM_Document_New_Version_Email_Body.

  2. Modify the Value field. For a list of supported merge fields, visit Supported merge fields.

  3. Click Save.

Supported merge fields

Custom labels for system event notifications only support merge fields for context record fields that are visible to the user.

System event

Supported context record types

Document Create

  • documentVersion

Document Delete

  • documentVersion

Document New Version Upload

  • documentVersion

Document Version Delete

  • documentVersion

Document New Draft

  • documentVersion

Document State Change

  • documentVersion

Document State Entry Obsolete

  • documentVersion

Document State Entry Published

  • documentVersion

Document State Entry Withdrawn

  • documentVersion

Document State Entry Draft

  • documentVersion

Document Upcoming Expiration

  • documentVersion

Document Metadata Update

  • documentVersion

  • lastModifiedBy

Workflow Start

  • documentVersion

  • workflowInstance

Document Relationship Create

  • documentVersion1

  • documentVersion2

  • documentRelationship

  • product

Document Relationship Delete

  • documentVersion1

  • documentVersion2

  • documentRelationship

  • product

Document Region Create

  • documentVersion

  • region

Document Region Delete

  • documentVersion

  • region

Workflow Task Assignment

  • documentVersion

  • Task

Workflow Task Update

  • documentVersion

  • Task

Out-of-the-box system events

These System Event (mvn__SE_System_Event__mdt) records exist out-of-the-box:

  • PP_Sum_Data_Document_New_Version_Upload

  • PP_Pub_Document_New_Version_Upload

  • PP_Task_Assignment

Disable notifications

You can disable all system event notifications if you do not want to use any in your Salesforce instance or if you want to perform a data load. To disable the notifications for all System Event (mvn__SE_System_Event__mdt) metadata records, create a System Event Setting (mvn__SE_System_Event_Setting__mdt) metadata record and check one or both of the disable options below:

  • Disable Chatter Posts - indicates if Chatter post notifications for system events are disabled (true) or enabled (false).

  • Disable Notifications - indicates if all notification channels for system events are disabled (true) or enabled (false).

You can also grant users the ability to mute all document system event notifications for a specific document type. To grant this ability for a designated document collaborator role, create a Document Type Role Permission (mvn__CM_Document_Type_Role_Permission__mdt) metadata record as follows:

  1. Set the Document Type and Role fields according to the document and document collaborator that you want to enable the feature for.

    For example, if you want a reviewer to be able to mute notifications for a publication document, set the Document Type field to Publication and set the Role field to Reviewer.

  2. Set the Permission field to Mute Notifications. This is the Mute Notifications (CM_Mute_Notifications) Permission (mvn__CM_Permission__mdt) metadata record that will mute all document system event notifications for the document.

Once configured, the Role Permissions matrix for the specified role will show a checkmark next to "Mute Notifications". Additionally, document collaborators with the specified role on a document of the designated document type will be able to click Mute Notifications on the Document (mvn__CM_Document__c) record. By clicking Mute Notifications, no notifications will be sent out to any collaborators on the document. This applies to all Document System Event Notification (mvn__CM_Document_System_Event_Notification__mdt) metadata records configured for the document. However, these document-level notification settings are superseded by task-level notification settings. For more information about notification management on activities and tasks, reference Email notifications.

KPP_MuteNotificationsRolePermissions.png
KPP_MuteNotificationsOption.png

Metadata

These are the primary custom metadata types used to configure system events:

  • Document Notification Audience (mvn__CM_Document_Notification_Audience__mdt) - defines target audiences for system event notifications. Target audience can be based on a Document Role, Group, Salesforce user ID, or user query filter. When defining a target audience based on Document Role, you must specify the Document Context in which the document role is notified.

  • Document System Event Notification (mvn__CM_Document_System_Event_Notification__mdt) - manages how system event notifications are sent to users via Salesforce notifications and emails.

  • System Event (mvn__SE_System_Event__mdt) - defines system wide events that can be listened and processed using a configured custom Apex class.

  • System Event Configuration (mvn__SE_System_Event_Configuration__mdt) - configures handlers for system events.

  • System Event Setting (mvn__SE_System_Event_Setting__mdt) - contains configuration settings that affect all system events.

Document System Event Notification entity relationship diagram