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
sfdev179sfdev179 

Reassign activities to accounts from leads

I want to assign activities related list From lead to Accounts without converting the leads.The trigger runs when the Value in a custom field 'auction access id' matches the value of the same field on acount object.The part of the code that reassigns activities is as follows:

 

for(Account actts : mapOfAccounts.values()){
if(ActivityHistoryMap.containsKey(actts.auction_access_Id__c)){

for(ActivityHistory ah :ActivityHistoryMap.get(actts.auction_access_Id__c)){


ah.WhoID = null ;
ah.WhatID = actts.Id ;


}
}

 

 

however i get this error: : Compile Error: Field is not writeable: ActivityHistory.WhoId

 

please help on how to reassign activities using this code or another that would do the job.

Thanks

kevin lamkevin lam

You need to run your updates through the list of Events or Tasks.

sushant sussushant sus
ActivityHistory is read only object . so you cant perform any operation

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_activityhistory.htm