• mamatha devaraj
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I wrote this code but it is not working, help me for this

Thanks in advance

trigger FindDuplicatecases on Case (after insert) {
    system.debug('tset');
    
    String policyVariable;
    String typevalue;
    Datetime createdDateValue;
    List<Case> caseList = New List<Case>();
    List<Case> cadup = New List<Case>();
    Set<Case> caseSet = New Set<Case>();
    
    for(Case c:trigger.new){
        if(c.policy__c != null && c.Type == 'QRC'){
            policyVariable = c.policy__c;
            typevalue = c.Type;
            createdDateValue = c.CreatedDate;
        }
    }
    system.debug('policyVariable>>> '+policyVariable);
    system.debug('typevalue>>> '+typevalue);
    
    if(policyVariable != null && typevalue == 'QRC'){
        system.debug('in>>>> ');
        cadup =[select id, policy__c, Type, ParentId from case where policy__c =: policyVariable  AND Type = 'QRC' ];
    }
    system.debug('cadup>>>> '+cadup);
    
    if(cadup.size() > 0){
        for(case cs : trigger.new){
            for(case cse : cadup){
     system.debug('oldcaseid'+cse);
                Case ce = New Case();
                ce.Id = cs.Id;
                ce.ParentId = cse.Id;
                caseSet.add(ce);
            }
        }
    }
    system.debug('caseSet>>>> '+caseSet);
    
    for(Case csSet : caseSet){
        caseList.add(csSet);
    }
    
  
        Update caseList;
    
}
I wrote this code but it is not working, help me for this

Thanks in advance

trigger FindDuplicatecases on Case (after insert) {
    system.debug('tset');
    
    String policyVariable;
    String typevalue;
    Datetime createdDateValue;
    List<Case> caseList = New List<Case>();
    List<Case> cadup = New List<Case>();
    Set<Case> caseSet = New Set<Case>();
    
    for(Case c:trigger.new){
        if(c.policy__c != null && c.Type == 'QRC'){
            policyVariable = c.policy__c;
            typevalue = c.Type;
            createdDateValue = c.CreatedDate;
        }
    }
    system.debug('policyVariable>>> '+policyVariable);
    system.debug('typevalue>>> '+typevalue);
    
    if(policyVariable != null && typevalue == 'QRC'){
        system.debug('in>>>> ');
        cadup =[select id, policy__c, Type, ParentId from case where policy__c =: policyVariable  AND Type = 'QRC' ];
    }
    system.debug('cadup>>>> '+cadup);
    
    if(cadup.size() > 0){
        for(case cs : trigger.new){
            for(case cse : cadup){
     system.debug('oldcaseid'+cse);
                Case ce = New Case();
                ce.Id = cs.Id;
                ce.ParentId = cse.Id;
                caseSet.add(ce);
            }
        }
    }
    system.debug('caseSet>>>> '+caseSet);
    
    for(Case csSet : caseSet){
        caseList.add(csSet);
    }
    
  
        Update caseList;
    
}