You need to sign in to do that
Don't have an account?
Test method issue - EventRelation object
Hello There!
I've created a trigger on the Event object and this triggers updates a boolean flag on the Event object, if the Event is a multi person event(There are some other business rules that I'm validatiing in the trigger)
The issue here is after inserting the EventRelation record in the test method. It does not update the event record but when I query the event record I see that the IsGroupEvent std field is getting updated to TRUE.
Now if I update the the event record by writing the dml update statement in the test method its changing this flag to false( IsGroupEvent =false)
and because of this my apex code is not getting covered.
I've added the code snippet below:
EventRelation er = new EventRelation(EventId =ev.id,
RelationId = lead.Id, Status='New' );
insert er; //inserting EventRelation
ev = [SELECT Id, Subject, ActivityDate, ActivityDateTime, IsGroupEvent FROM Event WHERE Id = :ev.Id LIMIT 1];
system.debug('**ev is*'+ev);
here in the debug I see the IsGroupEvent(this field is not writable) is set to TRUE.
update ev;
after this dummy update its changing the flag to false.
any idea why?
I've created a trigger on the Event object and this triggers updates a boolean flag on the Event object, if the Event is a multi person event(There are some other business rules that I'm validatiing in the trigger)
The issue here is after inserting the EventRelation record in the test method. It does not update the event record but when I query the event record I see that the IsGroupEvent std field is getting updated to TRUE.
Now if I update the the event record by writing the dml update statement in the test method its changing this flag to false( IsGroupEvent =false)
and because of this my apex code is not getting covered.
I've added the code snippet below:
EventRelation er = new EventRelation(EventId =ev.id,
RelationId = lead.Id, Status='New' );
insert er; //inserting EventRelation
ev = [SELECT Id, Subject, ActivityDate, ActivityDateTime, IsGroupEvent FROM Event WHERE Id = :ev.Id LIMIT 1];
system.debug('**ev is*'+ev);
here in the debug I see the IsGroupEvent(this field is not writable) is set to TRUE.
update ev;
after this dummy update its changing the flag to false.
any idea why?
Are you creating this event from the test class ?
As you must be aware that data does not commit to database when you are doing it through test methods..
Are you saying that your actual data is getting updating from a test class?