I have a requirement where a customer will export their case data however, they also want to remove/mask any PII data from the case export.

All that I have read on this topic is platform encryption or data masking for sandbox etc. This will not work for a data export if I understand.

Can anyone suggest a way to achieve this? Can this be done in a data export or data loader perhaps?

I am also thinking if not possible in the export then is there a way to run some job on a csv file that will achieve this? Any excel tools/tips here?

Thanks in advance.

  • 1
    why not just exclude those columns from the export?
    – cropredy
    Commented Oct 10, 2020 at 17:49
  • Sure, but what if the data is contained within the subject and description fields which are pretty critical. Commented Oct 10, 2020 at 22:52
  • Create shadow fields for subject and description and mask sensitive bits using apex code. You'll need to mass update all existing records though. Then export the shadow fields
    – cropredy
    Commented Oct 10, 2020 at 23:13
  • I dont think that will work since this is the customer's instance. I will have to ask them to do this in production, do not think they will agree to this. Any other suggestion? Commented Oct 11, 2020 at 18:22
  • 2
    Post process the CSV file then by a trusted user. Repost this question on the Excel forum(s)
    – cropredy
    Commented Oct 11, 2020 at 19:15

1 Answer 1


Option 1 - Add shadow fields to Case

  • Case.Description_Masked__c
  • Case.Subject_Masked__c

Write an Apex trigger on Case to copy/mask values from the OOTB fields to the xxx_Masked__c fields. You will most likely need to use regex (Pattern and Matcher classes as suggested by @MaxGoldfarb above)

You will also need to apply this trigger to all existing records to create masked values

  • Then, use Data Loader or Reports to export the masked fields in lieu of the OOTB fields

Option 2

If you are unable to add new fields / trigger to the Case object as you indicated in the comments:

  • Use a trusted user to export the unmasked data to Excel
  • Apply excel formulas or VBA to the unmasked fields to create masked values (consult excel forums for best way to do this given your specifics)
  • delete the columns for the unmasked data
  • rinse and repeat every time you need to export

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .