• Matt Parker 1
  • 0 Points
  • Member since 2015

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
Hi there,

Is there way to remove or blank credit card details from incoming emails to salesforce 
Hi All,

I want to mask credit card number in Case Description field. Whenever case get created in sfdc if case description field contains any credit card number, I just wanted to mask credit card number. For example if anyone enter credit card number like 4346-7810-4356-6678 in case description, After saving the case Credit card number should be look like as xxxx-xxxx-xxxx-xxxx. I have also tried to write trigger on Case object. But it is not working properly. It is making all number as cross(x) in case description field. Please find below code:
trigger testMaskCC on Case(before insert){
 if(trigger.isBefore && trigger.isInsert){ 
        CreditCard_No_Masking_OnCase NewCase= new CreditCard_No_Masking_OnCase();

Trigger Class
public class CreditCard_No_Masking_OnCase{

    public void newCaseInsert(list<Case> newList){
    String reGexVisa='4[0-9]{12}(?:[0-9]{3})';
    Pattern regexPattern = Pattern.compile(reGexVisa);
        for(case cs : newList){
           String withOutSpec=(cs.description).replaceAll('[-, +]','');
           Matcher regexMatcher = regexPattern.matcher(withOutSpec);
            system.debug('-------------group count----'+regexMatcher.groupCount());
              Integer countGroup=0;
              String  matchValue=regexMatcher.group(countGroup);
              cs.description= String.valueOf(cs.description).replaceAll('[0-9]', 'X');

And also I am using regex for idetifying different companies's credit card number like Visa Card: ^4[0-9]{12}(?:[0-9]{3})?$  Mastercard: ^5[1-5][0-9]{14}$.

Please help me to generalized Regex(I wanted to use one Regex to identify different comany's credit card instead of using different company's regex) and Mask the Credit Card number only.
Any Help in this regard would be much appriciated.

  • June 02, 2016
  • Like
  • 0