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
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..