• GFT Tim
  • NEWBIE
  • 15 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Below is my code. The case record through debug log says it updates however it does not populate the field on the record.  When I run the code through Developer Console and run it anonyomusly the code runs properly and the field populates on the record.  
This code is part of a TriggerHandler class for Case on BeforeUpdate.  Basically anytime a case is update where:
Case Reason = Withdrawal
Case Sub_Type__c = Multiple
and I get the Banking_Site value from the first record in the related list Failed_Transactions
and populate the case field ExtAPIBankSite__c with the value.



        set<ID> myCase = new set<ID>();
        list<Case> cList = new list<case>();
        Map<Id,String> cMap = new map<Id,String>();
       
        for(Case c : lstCases){
            if(c.Reason == 'Withdrawal' && c.Sub_Type__c == 'Multiple'){
                if(c.ExtAPIBankSite__c == null){
                    myCase.add(c.id);  
                }                                   
            }
        }
       
       cList = [SELECT Id,ExtAPIBankSite__c,(SELECT Id,Banking_Sites__c FROM Failed_Transactions__r ORDER BY Process_Order__c ASC Limit 1)FROM      Case WHERE Id in:myCase];
       
        for(Case cLoop : cList){                     
            cMap.put(cLoop.Id,cLoop.Failed_Transactions__r[0].Banking_Sites__c);
            if(cMap.get(cLoop.Id)!= null){                               
                 cLoop.ExtAPIBankSite__c = cMap.get(cLoop.Id);
            }
        }
     }
Below is my code. The case record through debug log says it updates however it does not populate the field on the record.  When I run the code through Developer Console and run it anonyomusly the code runs properly and the field populates on the record.  
This code is part of a TriggerHandler class for Case on BeforeUpdate.  Basically anytime a case is update where:
Case Reason = Withdrawal
Case Sub_Type__c = Multiple
and I get the Banking_Site value from the first record in the related list Failed_Transactions
and populate the case field ExtAPIBankSite__c with the value.



        set<ID> myCase = new set<ID>();
        list<Case> cList = new list<case>();
        Map<Id,String> cMap = new map<Id,String>();
       
        for(Case c : lstCases){
            if(c.Reason == 'Withdrawal' && c.Sub_Type__c == 'Multiple'){
                if(c.ExtAPIBankSite__c == null){
                    myCase.add(c.id);  
                }                                   
            }
        }
       
       cList = [SELECT Id,ExtAPIBankSite__c,(SELECT Id,Banking_Sites__c FROM Failed_Transactions__r ORDER BY Process_Order__c ASC Limit 1)FROM      Case WHERE Id in:myCase];
       
        for(Case cLoop : cList){                     
            cMap.put(cLoop.Id,cLoop.Failed_Transactions__r[0].Banking_Sites__c);
            if(cMap.get(cLoop.Id)!= null){                               
                 cLoop.ExtAPIBankSite__c = cMap.get(cLoop.Id);
            }
        }
     }