i created a trigger (EventBeforeInsert) that use the WhoID of the event to do other things, it works perfectly in the classic but in lightning this particular field is null in my code although the contact is attached to the event in the lightning UI (thus, WhoID should not be null), i tried to figure out if there is another field specifically used in lightning instead of WhoID but i found nothing, do you have an idea ? here is a screen shot to an event just before being created (you can see the contact attach to the event):

enter image description here

My trigger code is just a call to another method:

trigger EventBeforeInsert on Event (before insert) {

    System.debug('########### trigger BEGIN: EventBeforeInsert#####################');

    System.debug('########### trigger END: EventBeforeInsert#####################');  

Here is the developer console debug, the whoID is null:

enter image description here

  • How are you creating the Event in the Lightning UI? Can you give us a screen capture and also post the code for your trigger? Please read How do I ask a good question. – crmprogdev Jan 24 '17 at 13:55
  • I have edited my question – Merabti Ibrahim Jan 24 '17 at 14:15
  • Seeing the method would be helpful. Is this a custom event page we're looking at? I see that it's in a different language is why I'm asking. I see in your debug output the who count. Do you have "Allow Users to relate Multiple Contacts to Tasks & Events" enabled in Lightning? It's under Setup>Sales>ActivitySettings. – crmprogdev Jan 24 '17 at 14:29
  • No it's the standard page, it's just french. For the method i can post it but as you can see in the trigger code, i added a system.debug() before calling the method just to test the content of the trigger.new list ans as you can see in the screen capture below the whoID is already null so , the method i am calling just after does not interfere in any way (that 's my opinion) . also the "Allow Users to relate Multiple Contacts to Tasks & Events" is enabled in my lightning environment. it's really weird this problem, it's driving me crazy – Merabti Ibrahim Jan 24 '17 at 14:37
  • @crmprogdev can you please try it by creating a dummy trigger to verify if the problem is just in my environment or in lightning ? – Merabti Ibrahim Jan 24 '17 at 14:45

Here's what's happening. Because you have "Allow Users to relate Multiple Contacts to Tasks & Events" enabled, you likely have IsGroupEvent set to true by default, in which case you need to be using EventWhoIds instead of the WhoId in your trigger.

Otherwise, you need to set IsGroupEvent = false in your dialogue so the contact will be used for the WhoId instead of being added to the string of EventWhoIds.

  • I will try it right now and keep you updated – Merabti Ibrahim Jan 24 '17 at 17:18
  • I meant to add this link from the the Object Reference. – crmprogdev Jan 24 '17 at 17:24
  • 1
    great answer and would apply to Classic as well – cropredy Jan 24 '17 at 18:49
  • @crmprogdev unfortunately the IsGroupEvent is already equal to false and the EventWhoIds returns an empty list. thank you any way for the answer. – Merabti Ibrahim Jan 25 '17 at 9:33
  • If that's what's happening, I recommend you file a case with Salesforce. This sounds like a bug to me. – crmprogdev Jan 25 '17 at 13:16

I have exactly the same problem. Event.whoid field was not accessible in before Event Trigger.

I have opened a case to Salesforce support, which they marked as a bug. Known Issue page.

while waiting the fix, there are 2 workarounds:

  • Disable "Shared Activities should result in the WhoId being populated.

  • If "Allow Users to Relate Multiple Contacts to Tasks and Events" is disabled, you will get the WhoID no matter the trigger run under "before insert" or "after insert".

    • If "Allow Users to Relate Multiple Contacts to Tasks and Events" is enabled, you will get the WhoID only under "after insert", not under "before insert. "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.