• Hayato Kawajiri
  • 0 Points
  • Member since 2019

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1
I created a trigger on case. Member_ID__c is a auto-number field on contact object. I am trying to find out repeat cases logged by a contact using custom checkbox Repeat_Caller__c on case. There are many other conditions, but I removed them in this code for simplicity. I am not able to match Member_ID__c field in cases even though multiple cases are created by the same contact. In other words, I am not able to enter the IF condition. I have pasted the trigger below.

Please guide me as to where the problem might be. Any help is appreciated.

trigger repeatCase1 on Case (before insert,before update) {
    List<Case> caseList = trigger.new;   
    Set<id> memberIdSet = new set<id>();
    for(case c: caseList){
      List<Case> allcase = [select Contact.Member_ID__c from case where contact.Member_ID__c IN: memberIdSet];               
      for(Case cs: caseList ){  
        for(Case all: allcase ){ 
            if(cs.contact.Member_ID__c == all.contact.Member_ID__c ){