You need to sign in to do that
Don't have an account?
JN22
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY Error
Hello,
I have a trigger (see below) that works in my Sandbox and is covered by my test in my sandbox. When I try to deploy to production, I get the error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UniqueDelivID: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.UniqueDelivID: line 15, column 1: []
Can anyone help as to why I am getting this error?
Trigger:
I have a trigger (see below) that works in my Sandbox and is covered by my test in my sandbox. When I try to deploy to production, I get the error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, UniqueDelivID: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.UniqueDelivID: line 15, column 1: []
Can anyone help as to why I am getting this error?
Trigger:
//Assigns a unique ID to each deliverable in every Opportunity so DyNad can track. trigger UniqueDelivID on OpportunityLineItem (before insert, before update) { Set<ID> setOliIds = new Set<ID>(); for(OpportunityLineItem oli:Trigger.new){ setOliIds.add(oli.Id); } Map<ID, OpportunityLineItem> mapOli = new Map<ID, OpportunityLineItem>([SELECT Id, Opportunity.Max_Deliv_Hx__c, Max_Deliv__c FROM OpportunityLineItem WHERE Id in:setOliIds]); if(mapOli.size()>0){ for(OpportunityLineItem oli1:Trigger.New){ IF(mapOli.containsKey(oli1.Id) && oli1.Max_Deliv__c == null){ oli1.Max_Deliv__c = mapOli.get(oli1.Id).Opportunity.Max_Deliv_Hx__c + 1; } } } }
Can you make sure of the following things in production.
1) Check if you have access to Max_Deliv_Hx__c field .
2) Make Max_Deliv_Hx__c default to zero .
This should fix your problem.
Thank You.
Can you put a debug statement right after line 14 , to check for the map values and Max_Deliv__c value.
Thanks