function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Puneet KhoslaPuneet Khosla 

Update WhoId from Apex Class on Event if Shared Activities is turned on

I am getting the following error when trying to change the WhoId of an event (Shared Activities is turned on).
The update is happening from a Custom Visualforce Page and Apex Class.
Input field for whoId is used in the Visualforce Page and class uses and upsert.

Upsert failed. First exception on row 0 with id 00U25000001XYDWEA4; first error: INVALID_CROSS_REFERENCE_KEY, Updating the whoId fields for shared activities is not allowed.: [WhoId]

Is there a way to update the who Id from a custom Apex / VF page when Shared Activities is switched on?

There is a trigger on Event but that is not creating any Event Relation records
ManojjenaManojjena
Hi Puneet,
Can you please tell what record Id you are assigning to Whatid in your code .

 
Puneet KhoslaPuneet Khosla
WhatId would be Account (which may not be the account of primary contact)