- 13 Jul 2022
- 1 Minute to read
- Print
- DarkLight
Extend Blackthorn Compliance to Other Objects
- Updated on 13 Jul 2022
- 1 Minute to read
- Print
- DarkLight
Blackthorn Compliance comes preloaded with Detection and Auditing for many standard objects, but what if you want to detect credit cards on custom objects or other standard objects?
Part One: Create a new Manager Record
Create new Compliance Manager Record. Go to Setup > Custom Code > Custom Metadata Types > Manager > Manager Records > New.
Enter the API Name of the Object in the
Label
field (must be exact API Name).
Enter the Name of the Object in the
Manager Name
field (cannot contain consecutive underscores).Enter the comma-delimited API names for Salesforce fields in
Detection Fields
(must be less than 255 characters).- Do not add any trailing commas or spaces.
- Any fields which are over 255 characters will not be included in masking.
- If you need more than 255 characters, add your additional fields to
DetectionFieldsPlus
.
Select a
Detection Action
.Press Save.
Part Two: Extend Compliance with an Apex Trigger
NOTE: If you are running Compliance Audits only, then you can skip this step. If you don’t need new records to be processed and are only cleaning up old records, you can skip this step.
Now we’ll need to get a little advanced by writing a super easy Apex Trigger on the Object you are extending Compliance to.
Create a new Apex Trigger for the Object:
- Classic: Setup > Create > Objects > Click on the Object name > Triggers > New
- Lightning: Setup > Object Manager > Click on the Object name > Triggers > New
Copy & Paste the following lines of code (replacing all “NewHouse” references with the API name of the Object you wish to extend PCIFY to).
trigger NewHouseTrigger on NewHouse (before insert, before update) { if (pcify.Manager.isOnline('NewHouse')) { pcify.Processor.maskCreditCards( Trigger.new, pcify.Manager.getMaskFields('NewHouse'), 'NewHouse' ); }}
- Press Save.
- Navigate back to the Compliance App.
- Turn on Detection for the Object.
You should see the following alert notification.
Congratulations! You have successfully added a new Object to Compliance.