function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Super User ALTENSuper User ALTEN 

The trigger in a production environment does not work

Hi,
we have a problem in my org ID is "00Dw0000000nMNj".
I developed a trigger for pre-production environment and this creates records in an object correctly.
I brought the same trigger in a production environment and that does not create the records.
What could be the problem?
How can I solve it?

Please email me at alessia.lombardo@alten.it <mailto: alessia.lombardo@alten.it>
I am waiting for an answer.
Thanks a lot
Alessia Lombardo
 
Jha dilipJha dilip
Hi Alessia
please check this link and try it may help https://developer.salesforce.com/forums/?id=906F000000092VpIAI

Regards
Dilip
Amit Chaudhary 8Amit Chaudhary 8
Please post your code here so that we can help you
SuperUser SuperUserSuperUser SuperUser
Hi, thanks in advance.

TRIGGER ITC_Incident_TimeTrack:

trigger ITC_Incident_TimeTrack on BMCServiceDesk__Incident__c (before update, before insert) {
    IncidentTimeTracking__c TimeTrackTMP = new IncidentTimeTracking__c();
    
    for (BMCServiceDesk__Incident__c Incident: Trigger.new) { 
        if (Trigger.isupdate) {
        BMCServiceDesk__Incident__c IncidentOld = System.Trigger.oldMap.get(Incident.Id);
        
        if (Incident.BMCServiceDesk__queueName__c != IncidentOld.BMCServiceDesk__queueName__c && IncidentOld.BMCServiceDesk__queueName__c == NULL)
                  {Incident.ApexDataStart__c = System.now(); }
      
       if (Incident.BMCServiceDesk__state__c != IncidentOld.BMCServiceDesk__state__c && Incident.BMCServiceDesk__state__c == True)
                  {Incident.ApexDataStart__c = System.now();
                    Incident.ApexDataEnd__c =  NULL;}      
 
 if (Incident.BMCServiceDesk__queueName__c != IncidentOld.BMCServiceDesk__queueName__c 
     && IncidentOld.BMCServiceDesk__queueName__c != NULL
     && Incident.ITC_BusinessHour__c != NULL) {    
     Incident.ApexDataEnd__c = System.now();
     Incident.ApexGroup__c = IncidentOld.BMCServiceDesk__queueName__c; 
     TimeTrackTMP.Incident__c = Incident.id;
     TimeTrackTMP.BMCServiceDesk_queueName__c = Incident.ApexGroup__c;
     If (Incident.ITC_Request_Type__c == 'Incident') { 
                                                    TimeTrackTMP.Object_Type__C = 'Incident';  } 
                                            else    {TimeTrackTMP.Object_Type__C = 'ServiceRequest';}

     TimeTrackTMP.Operation_Type__C = 'Group';
     TimeTrackTMP.name = Incident.name;
     TimeTrackTMP.Start_Date__c = Incident.ApexDataStart__c;
     TimeTrackTMP.End_Date__c = Incident.ApexDataEnd__c;
     TimeTrackTMP.ITC_BusinessHour__c = Incident.ITC_BusinessHour__c;
     Incident.ApexDataStart__c = System.now();
     Incident.ApexDataEnd__c =  NULL;
}
           
  if (IncidentOld.BMCServiceDesk__state__c == TRUE 
      && Incident.BMCServiceDesk__state__c == FALSE
      && Incident.ITC_BusinessHour__c != NULL)
      { 
     Incident.ApexDataEnd__c = System.now();         
     TimeTrackTMP.Incident__c = Incident.id;
     TimeTrackTMP.BMCServiceDesk_queueName__c = Incident.BMCServiceDesk__queueName__c;
     If (Incident.ITC_Request_Type__c == 'Incident') { 
                                                    TimeTrackTMP.Object_Type__C = 'Incident'; } 
                                            else    {TimeTrackTMP.Object_Type__C = 'ServiceRequest';}

     TimeTrackTMP.Operation_Type__C = 'Object Closure';
     TimeTrackTMP.name = Incident.name;
     TimeTrackTMP.Start_Date__c = Incident.ApexDataStart__c;
     TimeTrackTMP.End_Date__c = Incident.ApexDataEnd__c;
     TimeTrackTMP.ITC_BusinessHour__c = Incident.ITC_BusinessHour__c;
      } }
        
         if (Trigger.isinsert) {
             Incident.ApexDataStart__c = System.now(); 
                            } }

if(TriggerHandler.firstRun) {       
    if (TimeTrackTMP.name != NULL && TimeTrackTMP.End_Date__c != NULL && TimeTrackTMP.Start_Date__c != NULL) {
    Insert(TimeTrackTMP);
  TriggerHandler.firstRun = false; }}
    }



TRIGGER ITC_TimeTrackingCalculate:

trigger ITC_TimeTrackingCalculate on IncidentTimeTracking__c (before insert) {

    for (IncidentTimeTracking__c TimeTrack: Trigger.new) {  
    if (TimeTrack.Operation_Type__c != 'PENDING' && TimeTrack.ITC_BusinessHour__c != NULL)
{
    TimeTrack.Working_Time__c = BusinessHours.diff(TimeTrack.ITC_BusinessHour__c, TimeTrack.Start_Date__c, TimeTrack.End_Date__c); } 

    else if (TimeTrack.ITC_BusinessHour__c != NULL)
          {
TimeTrack.Working_Time__c = -1*(BusinessHours.diff(TimeTrack.ITC_BusinessHour__c, TimeTrack.Start_Date__c, TimeTrack.End_Date__c)); 
 } } }