function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dave ScottDave Scott 

Checking / Removing any 8 digit account number on Cases

Hi folks, hope you can help.

I recently company policy change means that we're not allowed to have any 8 digit account numbers stored on cases received via Email-to-Case.

Is there any way to get Salesforce to alert the Salesforce admin of any instances or even possibly remove the 8 digit account numbers from the case entirely or blank out the first 5 digits perhaps?

Any help on this would be greatly appreciated.

Many thanks,
Dave
VeniRayVeniRay
Yes.It is possible through a trigger.
Dave ScottDave Scott
Thanks for that, do you have any ideas how I would go about this?

Many thanks,
Dave
crop1645v2crop1645v2
Is an account number a custom field on Case?  If yes, then you should be able to use Workflow and Field Updates to overwrite the value; no APEX required
Dave ScottDave Scott
No an account number is not a customer field.  An account number is a number a customer has provided us with in the body of an email when he/she constructs an email and sends it to our company email address which a case is created via Email-to-Case, and it's that 8 digit number that the customer has provided us with that needs to be removed from the email attached the case.
crop1645v2crop1645v2
Ah lovely -- you are going to need to do the following:
  1. Create a before insert trigger on Case
  2. Within the trigger code, you will need to locate all occurrences of the accountNumber.  This is going to take a Regex to do so and mastery of the SFDC Pattern and Matcher classes.
  3. Each located accountId can then be replaced or masked as required
  4. Assuming the trigger is written correctly and the masking is done on a field within Trigger.new, the database will not contain the exposed account number
crop1645v2crop1645v2
dscott21 -- I think you will also need a trigger on EmailMessage to wipe the accoutnNumber out of that record too (assuming you expose EmailMessage as a related list on Case)