• Aishwarya_Todkar
  • NEWBIE
  • 25 Points
  • Member since 2018


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi,
On Case trigger I am attaching an Entitlement with the name stored in custom settings.
I want to test it in test class. If anyone can help me out with this will be appreciated.

Thanks!
Hi,
I have created a case assignment rule where whenever case of specific record type  is created it is assigned to a Queue.
But I'm not able to test it in test class. Kindly help me with the solution for this.
Hi All,

I have written a trigger on Order object which will take the status of Order Start Date field from Order and copy the same on "Upgrade Order Date" field in accounts.

I am receiving System.NullPointerException and I am not able to find out where I am making mistakes or what I have done wrong.

Below is my trigger:
trigger OrderTrigger on Order (after insert) {
                
    OrderTriggerHandler orderhandler= new OrderTriggerHandler(trigger.new);
    
     if(trigger.isAfter && trigger.isInsert) {  
         orderhandler.HandleAfterInsert();
     }
    
}

Below is my trigger Handler:
 
public class OrderTriggerHandler {
   List<Order>newOrders;
 
    public OrderTriggerHandler(List<Order>newOrders){
        this.newOrders=newOrders;
        
    }
    
    public void HandleAfterInsert(){ 
       updateOrderUpgradeStatus();
    }
    
    
    public void updateOrderUpgradeStatus(){
        
         Map<ID, Account> parentAccts = new Map<ID, Account>(); //Making it a map instead of list for easier lookup
          //List<Id> listIds = new List<Id>();
            Set<Id> setIds=new Set<Id>();
        
            for (Order childObj : newOrders) {
            setIds.add(childObj.Name);
          }
        
            system.debug('The value is: ' + parentAccts);
            //parentAccts = new Map<Id, Account>([Select id,Name,Upgrade_Order_Date__c,(Select id,EffectiveDate,Name,Header_Id__c from Orders where RecordType.name = 'Upgrade Order' ORDER BY Header_Id__c DESC) from Account WHERE  ID IN :setIds AND RecordType.name = 'Recipient']);
          parentAccts = new Map<Id, Account>([Select id,Name,Upgrade_Order_Date__c,(Select id,Name,EffectiveDate,Header_Id__c,Status from Orders where RecordType.name = 'Upgrade Order' ORDER BY Header_Id__c DESC NULLS LAST) from Account WHERE  ID IN :setIds AND RecordType.name = 'Recipient' ]);
          for (Order order: newOrders){
              
            // if(Order.Type=='Upgrade Order'){
              
             Account myParentAcct = parentAccts.get(order.Name);
               system.debug('The value is: ' + myParentAcct);    
             myParentAcct.Upgrade_Order_Date__c= order.EffectiveDate;
              //order.EffectiveDate=myParentAcct.Upgrade_Order_Date__c;
             
              //}
          }
        system.debug('The value is: ' + parentAccts);
   		 update parentAccts.values();
         
            }
     
        
    }

I ran the query in workbench and getting few records as well but in debug logs "parentAccts" doesn'r returning any row and line
system.debug('The value is: ' + myParentAcct);

retuen null and  myParentAcct.Upgrade_Order_Date__c= order.EffectiveDate shows the attempt to de-reference a null object.

Kindly help/guide/suggests.
Any help will be greatly apprecaited

Many thanks in advance

Thanks & Regards,
Harjeet
  • September 05, 2018
  • Like
  • 0
Hi,
I have created a case assignment rule where whenever case of specific record type  is created it is assigned to a Queue.
But I'm not able to test it in test class. Kindly help me with the solution for this.