• Raveendra Vaka
  • NEWBIE
  • 10 Points
  • Member since 2014
  • Salesforce Consultant
  • Birlasoft

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
How to create more than 14 days Event record?

EX: i want run 6 months continually, but Salesforce allow max 14day,so how to split the date and creating multipule events

Any body help me...
Thanks,
i written the trigger for auto create event from custom object, below is my code

trigger AutoCreateSfdcEvent on SVMXC__SVMX_Event__c (after insert , after update ) {
     List<Event> lstevent = new List<Event>();
   for(SVMXC__SVMX_Event__c se : Trigger.New){
     if(Trigger.IsAfter && Trigger.IsInsert){
      Event e = new Event();  
       e.StartDateTime = se.SVMXC__StartDateTime__c;
       e.EndDateTime = se.SVMXC__EndDateTime__c;
       e.Subject = se.Name;
       e.OwnerId=se.Owner.id;
       e.WhatId=se.id;
     //  e.AssignedTo= se.SVMXC__Technician__c.id;
       //e.WhatId = se.SVMXC__WhatId__c;
       //e.WhoId = se.SVMXC__WhoId__c;            
          lstevent.add(e);
     }
   }
    Insert lstevent;  
}

so,I am getting error message. while record is creating in custom object                              "Review all error messages below to correct your data.
Apex trigger AutoCreateSfdcEvent caused an unexpected exception, contact your administrator: AutoCreateSfdcEvent: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]: Trigger.AutoCreateSfdcEvent: line 17, column 1
"

Any body help me asap... Thanks....
How to create more than 14 days Event record?

EX: i want run 6 months continually, but Salesforce allow max 14day,so how to split the date and creating multipule events

Any body help me...
Thanks,
i written the trigger for auto create event from custom object, below is my code

trigger AutoCreateSfdcEvent on SVMXC__SVMX_Event__c (after insert , after update ) {
     List<Event> lstevent = new List<Event>();
   for(SVMXC__SVMX_Event__c se : Trigger.New){
     if(Trigger.IsAfter && Trigger.IsInsert){
      Event e = new Event();  
       e.StartDateTime = se.SVMXC__StartDateTime__c;
       e.EndDateTime = se.SVMXC__EndDateTime__c;
       e.Subject = se.Name;
       e.OwnerId=se.Owner.id;
       e.WhatId=se.id;
     //  e.AssignedTo= se.SVMXC__Technician__c.id;
       //e.WhatId = se.SVMXC__WhatId__c;
       //e.WhoId = se.SVMXC__WhoId__c;            
          lstevent.add(e);
     }
   }
    Insert lstevent;  
}

so,I am getting error message. while record is creating in custom object                              "Review all error messages below to correct your data.
Apex trigger AutoCreateSfdcEvent caused an unexpected exception, contact your administrator: AutoCreateSfdcEvent: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]: Trigger.AutoCreateSfdcEvent: line 17, column 1
"

Any body help me asap... Thanks....