How To Write Custom Blackthorn Compliance Apex Triggers

Blackthorn Compliance comes with native Apex Triggers on select standard objects included in the Compliance package. But if you want to use your own triggers instead, you simply need to change the Manager field "Use Own Trigger". This field controls whether or not Compliance will execute its native triggers. In other words, you can override our apex triggers on: Case, CaseComment, Task, EmailMessage, LiveChatTranscript, FeedItem, FeedComment, Attachment, and ContentVersion.

Important:

If you are writing triggers on a Salesforce object not included in the Compliance package, you do not need to check the field Use Own Trigger.

  1. Navigate to the Manager Setting for the standard object, Setup > Develop > Custom Metadata Types > Manager > Manage Records > Click on the object name.

  2. Press Edit.

  1. Check Use Custom Trigger.
  1. Press Save.
  1. Create your own Apex Trigger using the code snippet below as an example.

Sample Custom PCIFY Apex Trigger

trigger InboundEmailMessageTrigger on EmailMessage (before insert) {       List incomingEms = new List();        // check if Detection is turned on for Email Message    if (pcify.Manager.getManager('EmailMessage').pcifyisActivec) {        // collect incoming emails        for (EmailMessage em : Trigger.new) {            if (em.Incoming) {                incomingEms.add(em);            }         }              // process only incoming emails with PCIFY        pcify.Processor.maskCreditCards(            incomingEms,            pcify.Manager.getMaskFields('EmailMessage'),            'EmailMessage'        );    }}

PCIFY Class Methods

List of methods you can call from the pcify namespace.

Class

Method

Parameters

Description

pcify.Processor

maskCreditCards()

• records : List
• fieldNames: List
• objectName: String

Void method for scanning text for PII

pcify.Manager

getManager()

• objectName: String

Returns Manager Custom Metadata Type for a given object

pcify.Manager

getMaskFields()

• objectName: String

Returns list of field names for a given object

pcify.Manager

getDetectionAction()

• objectName: String

Returns the DetectionAction for a given object


Did this page help you?