Trigger to update latest due date of task on Opportunity
Create a new custom field on opportunity called Update_Due_Date_of_Task__c (Date/Time) and create the below trigger on task object. Output : If there are multiple tasks on opportunity the above custom field will be updated by due date which is greater from all task's due date. Trigger updateLastActvtyUpdateOnOpty on Task(after update, after insert) { Datetime lastUpdatedDate; Set < String > whatIDs = new Set < String > (); for (Task tskObj: Trigger.new) { if (tskObj.whatId != null && tskObj.ActivityDate != null) { whatIDs.add(tskObj.whatId); } ...