• Pragadheeshwari A
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi,

 

i have a class which reads through all appointments from my custom object appointment__c and creates an event in SF. Things work fine on the sandbox and when i move it to production i get the below error.

 

Failure Message: "System.DmlException: Insert failed. First exception on row 40; first error: FIELD_INTEGRITY_EXCEPTION, Event duration cannot be negative: [DurationInMinutes]", Failure Stack Trace: "Class.SyncWithEvents.transfer: line 31, column 7 Class.TestSyncWithEvents.TestappSyncWithEvents: line 25, column 6 External entry ...

 

Public Class SyncWithEvents
{
    List<Appointment__c> app= new List<appointment__c>();
    public Integer no_of_appts {get;set;}
    List <Event> LstEvent= new List<Event>();
    
    public SyncWithEvents()
    {
    
           
    }
    public void transfer()
    {
     app=[select StartDateTime__c,EndDateTime__c,Status__c,Client__c,OwnerId   from Appointment__c 
                    where Sync_with_events__c=false];
                    System.debug('No of records+++++++++++++++++++++'+app.size());
          for (integer i=0;i<app.size();i++)
       // for(List<Appointment__c> app:[select StartDateTime__c,EndDateTime__c,Status__c,Client__c,OwnerId  from Appointment__c 
       //             where Sync_with_events__c=false])
        {
                        Event e = new Event();
                        e.StartDateTime = app[i].StartDateTime__c;
                        e.EndDateTime = app[i].EndDateTime__c;
                        e.Subject = 'Appt - '+app[i].Status__c;
                                       
                        e.WhoId=app[i].Client__c; 
                        e.OwnerId=app[i].OwnerId ;
                        app[i].Sync_with_events__c=true;
                        LstEvent.add(e);
      }
      insert LstEvent;
      update app;
      no_of_appts=LstEvent.size();
    }
    
}

 Here is the test class

 

public with sharing class TestSyncWithEvents {
	
	static testMethod void TestappSyncWithEvents() 
    {  
    	/*appointment__c a = new appointment__c();
        string year = '2011';
        string month = '12';
        string day = '27';
        string hour = '09';
        string minute = '30';
        string second = '00';
        string stringDate = year + '-' + month + '-' + day + ' ' + hour + ':' + minute +  ':' + second;

        Datetime myDate =    datetime.valueOf(stringDate);
        a.Name='Test Name';
        a.Appointment_Type__c='Call';
        a.Start_Date__c=date.parse('12/27/2011');
        a.Start_Time__c='09:30 AM';
        a.StartDateTime__c=myDate;
        a.EndDateTime__c=myDate.addMinutes(30);
        a.status__c='Tentative';
        a.Sync_with_events__c=false;
        insert a;*/
    	SyncWithEvents sw= new SyncWithEvents();
    	sw.transfer();
    }

}

 Any ideas on what could be causing the problem

  • October 13, 2011
  • Like
  • 0

Ok all here is one that I am running into Trouble with. I have a Trigger that is Before insert, before update.

It is validating the address via the postalcodes as well as ensuing a proper grouping for reporting using the County and State returned from the Zip look up.
It works great however I need to Accommodate for passing 2300+ accounts at one time.
Any one do a Bulk/Batch processing before insert, before update? I keep getting a recursive issue.