Take the 2-minute tour ×
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.
 public Event returnEventOppObj(Opportunity opp1, Sobject sobj){
        Event e2 = New Event(Subject='Call1',Type = 'Call1', StartDateTime = datetime.now(), EndDateTime = datetime.now(), Ownerid =userinfo.getUserId(), WhatId=opp1.id, 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
add comment

1 Answer 1

up vote 4 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
add comment

Your Answer

 
discard

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.