Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
 public Event returnEventOppObj(Opportunity opp1, Sobject sobj){
        Event e2 = New Event(Subject='Call1',Type = 'Call1', StartDateTime =, EndDateTime =, Ownerid =userinfo.getUserId(),, WhoId=sobj.Id);
        return e2;

if I call this method where sObject is Lead, it will throwing exception as:

FIELD_INTEGRITY_EXCEPTION, You can't relate a lead to an account or other object.: [WhatId]

share|improve this question
up vote 5 down vote accepted

from documentation

WhoId: Description: ID of a related Contact or Lead. If the WhoId refers to a lead, then the WhatId field must be empty. Label is Contact/Lead ID. If Shared Activities is enabled, this is the ID of a related Lead or primary Contact.

The same behavior you can observe when you want to add an event on the page manually. When you pick 'Lead' then 'Related To' is grayed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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