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
Joel FarberJoel Farber 

Apex Trigger: "TaskEventListener"

Hey Everyone!

I've been an admin with my Org for the last year and I'm uncovering some things that consultants have done in my Org prior to my arrival. I don't know much about development, so I'm hoping you might be able to help. I appreciate any help!

1. The consultant who created this trigger is no longer providing services, but still receives error notifications. His user is inactive, so I don't know how he's still receiving these. 

2. He created a trigger on Tasks that he called "TaskEventListener." I'm not sure what this does or if it's even necessary. He received an error email alert from this trigger. Error shown below in italics.

Subject: Developer script exception from IPC Inc. : TaskEventListener : TaskEventListener: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 006d000000WwBA0AAN; first error: FIELD_CUSTOM_VALIDATION_EXCEPTI...

Apex script unhandled trigger exception by user/organization: 005d0000003NkdD/00Dd0000000eKKE

TaskEventListener: execution of AfterUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id 006d000000WwBA0AAN; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, The Opportunity field "Follow Up Date" cannot be overdue. Please update to Today or another day in the future. Note: If you receive this error while editing a Task, you must first go to the related Opportunity and update this required information.: []


Here's the code to the Trigger:
1trigger TaskEventListener on Task (After Insert, After Update) {
2  if(trigger.IsAfter){
3    TaskUtility.PopulateOpportunityNextStep(trigger.new);
4    TaskUtility.PopulateAccountNextStep(trigger.new);
5  }
6}

 
Raj VakatiRaj Vakati
There is a validation rule on Opportunity that causes this issue.  "Follow Up Date cannot be overdue" is validation name on Opportunity Object  


System.DmlException: Update failed. First exception on row 0 with id 006d000000WwBA0AAN; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, The Opportunity field "Follow Up Date" cannot be overdue. Please update to Today or another day in the future. Note: If you receive this error while editing a Task, you must first go to the related Opportunity and update this required information.: []
 
Zhen Yueh LeanZhen Yueh Lean
Hi Joel, I suspect that the trigger will populate the due date of the new task that you are trying to create into a field named "Follow Up Date" in opportunity, and that hit into a validation error. You need to check if there is any validation rule in opportunity that is doing that. If no luck, you will need to look into the TaskUtility apex class.