We are trying to move a task from one contact to another in a trigger. The Task is created by ListEmail functionality.
We are getting an exception when re-assigning the WhoId.
Exception: Update failed. First exception on row 0 with id 00T1N00002TXv3jUAD; first error: FIELD_INTEGRITY_EXCEPTION, Related To ID: id value of incorrect type: 0XB1N000000XaCuWAK: [WhatId]
This is the sample code:
List<Task> task = [SELECT Id, RecordTypeId, WhoId, WhoCount, WhatCount, Subject, AccountId, TaskSubtype, AccountId__c, EmailListWhatID__c FROM Task where Id ='00T1N00002TXv3jUAD']; system.debug('task = ' + task); Task tk = task.get(0); tk.WhoId = '0031N00001UvZDpQAN'; database.update(tk);
(Pseudo-reparenting via a copy of the Task is similarly problematic. We cannot create a new Task where the WhatId is a ListEmail. We /can/ reparent the Task if we clear the WhatId, but this is not ideal.)