You need to sign in to do that
Don't have an account?
iKnowSFDC
Testing Event Trigger - Issue with IsGroupEvent Flag
Hi All,
I'm working on some test code for a trigger that flags a check box is the owner's user role and the invitee user role are part of a list defined in a custom setting. The trigger works as expected, however, when testing the trigger, I am not getting the isGroupEvent flag to populate. I've found several posts around this issue, but the solutions posted have not worked for me. Below is the code, any suggestions would be VERY appreciated.
I'm working on some test code for a trigger that flags a check box is the owner's user role and the invitee user role are part of a list defined in a custom setting. The trigger works as expected, however, when testing the trigger, I am not getting the isGroupEvent flag to populate. I've found several posts around this issue, but the solutions posted have not worked for me. Below is the code, any suggestions would be VERY appreciated.
@isTest private class testEventUpdateTrigger { private testMethod static void testEventTrigger(){ //find users with appropriate roles to generate joint meeting flag User BHFAUser = [SELECT id, UserRoleId, UserRole.Name FROM User WHERE UserRole.Name = 'Financial Advisor BHFA - Arizona FA' LIMIT 1]; User preferredUser = [SELECT id, UserRoleId, UserRole.Name FROM User WHERE UserRole.Name = 'Preferred - AZ Premier Bankers' LIMIT 1]; //test 1 - insert an event & verify that the joint meeting flag was set to false. system.runAs(BHFAUser){ Event e1 = new Event(Subject='Test', StartDateTime = date.today(), DurationInMinutes = 60); insert e1; system.assert(!e1.Joint_Meeting__c); //Add an Event Relation Record EventRelation er1 = new EventRelation(EventId = e1.id, RelationId = preferredUser.id, IsInvitee=true, Status='New'); insert er1; e1.Description = 'invited new user'; update e1; system.debug('is group event flag>>>'+e1.IsGroupEvent); //this assert is failing system.assert(e1.Joint_Meeting__c); } } }
I added a query before the system.assert but am still failing on the assert.
I confirmed that the once I requery the event, IsGroupMeetting is set to true, however, the trigger is not executiong and setting the joint meeting field to true as it should.
Is this an issue with creating an EventRelation record via APEX? I've also tried sending the event to the method directly via the test code but no luck. I've tested in the UI with users that have the profiles I've specified in the test code and it works as expected.
Then again requery the event before line 22 before outputing IsGroupEvent and asserting the joint_meeting__c flag is set.