+ Start a Discussion
Ben RezacBen Rezac 

TaskWhoRelation is not Writeable and barely Queryable throughout testing

I am attempting to create a TaskWhoRelation entry after a Task is created. IsAfter(IsInsert, isUpdate)

Has anyone successfully updated or inserted a TaskWhoRelation after task creation? I have all the information I need to create a Taskwhorelation but when I attempt to do so, it says that none of the fields are writeable.

Any help would be appreciated.

 
Shweta_AgarwalShweta_Agarwal
Hi Ben,

You can not update the same object record in Isafter, So if you want to update task who relation you have write your logic for before update or before Insert.For example you can refer below code.
 
trigger TaskTrigger on Task (before insert) {
	id contactId ='00390000020u8Ti';
    if(trigger.isBefore){
        for(Task eachRec : trigger.new){
        	eachRec.whoId = contactId;    
        }    
    }
}
Thanks,
Shweta