How To Write Custom Blackthorn Compliance Apex Triggers
  • 13 Jul 2022
  • 1 Minute to read
  • Dark

How To Write Custom Blackthorn Compliance Apex Triggers

  • Dark

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.
    manager detail edit

  3. Check Use Custom Trigger.
    check use custom trigger

  4. Press Save.
    use custom trigger is checked

  5. 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 : {            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 Compliance namespace.

Class Method Parameters Description
pcify.Processor maskCreditCards() records: List Void method for scanning text for PII
fieldNames: List
objectName: String
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