trigger TaskTrigger on Task (after update) { for(Task newTask : Trigger.New){ // Task.WhoId != null ----Checks Contact is null or not // ((string)Task.WhoId).startsWith('003') ----Checks Task is related to Contact // Task.WhatId == null ----Checks the related to field is null or not if(Task.WhoId != null && ((string)Task.WhoId).startsWith('003') && Task.WhatId == null ){ // Add your code as per your needs. } } }