+ Start a Discussion
rahul soni 20rahul soni 20 

how to display one of the keyword in child case?

trigger checkSecretInformation on Case (after insert, before update) {
    String childCaseSubject = 'case may contaions secrect info';
    
            // 1. create a collection that having each secrect keyword
		     List<String> secrectKeywords = new List<String>();
                secrectKeywords.add('credit card');
                secrectKeywords.add('credit card');
                secrectKeywords.add('social security');
                secrectKeywords.add('ssn');
                secrectKeywords.add('passport');
                secrectKeywords.add('bodyweight');
    
     // 2. check if our case contaions any secrect keyword 
      List<Case>	caseWithSecrectInfo = new List<Case>();
    for(Case myCase :Trigger.new) {
        if(myCase.Subject != childCaseSubject){
        for (String keyword : secrectKeywords) {
             if(myCase.Description != null && myCase.Description.containsIgnoreCase(keyword)){
                caseWithSecrectInfo.add(myCase);
                 System.debug('Case' + myCase.Id + 'include secrect keyword ' + keyword);
                 break;
             }
        }
        }
     
    }
  
  // 3. create a child case, if secrect keyword is there
  List<Case> casestoCreate = new List<Case>();
    for(Case caseWithSecrectInfo : caseWithSecrectInfo ) {
        Case childCase           = new Case();
        childCase.Subject        = childCaseSubject;
        childCase.ParentId       = caseWithSecrectInfo.Id;
        childCase.IsEscalated    = true;
        childCase.Priority       = 'High';
        childCase.Description    = 'Atleast one of the secrect keyword found' + secrectKeywords;
        casestoCreate.add(childCase);
 
    }
    insert childCase;
    }

Secret keyword listed, child case need to create if any word includes,,

How can I display that particular keyword in the child's case?

New to developing.. explanation will be helpful..