Question: Dynamic Event Priority Assessment Based on Task Proximity and Completion EventPro recognizes that not all open tasks have the same impact on event success, and
Dynamic Event Priority Assessment Based on Task Proximity and Completion
EventPro recognizes that not all open tasks have the same impact on event success, and tasks closer to the event date may require more immediate attention. To address this, EventPro wants to enhance the Event Flag calculation by considering the percentage of open tasks and the proximity of the event date. If more than of the tasks are open and the event date is within days, the event will be marked as "Critical" to highlight the urgency of pending tasks.
Step : Create a Trigger on the Event Task Object
Create a trigger on the Event Task object that invokes a trigger handler class to calculate and update the Event Flag based on specified criteria.
Trigger Name: EventTaskHealthCheckTrigger
Trigger Handler Class Name: EventTaskHealthCheckTriggerHandler
Description: This trigger ensures that when Event Task records are inserted, updated, or deleted, the corresponding trigger handler class is invoked to update the Event Flag status.
Hint
trigger EventTaskHealthCheckTrigger on EventTaskc after insert, after update, after delete
if TriggerisAfter
EventTaskHealthCheckTriggerHandler handler new EventTaskHealthCheckTriggerHandler;
if TriggerisInsert
Call the handlerAfterInsert method from the handler class
Pass Trigger.new as the parameter
else if TriggerisUpdate
Call the handlerAfterUpdate method from the handler class
Pass Trigger.new and Trigger.oldMap as parameters
else if TriggerisDelete
Call the handlerAfterDelete method from the handler class
Pass Trigger.old as the parameter
Step : Create a Trigger Handler Class
Trigger Handler Class Name: EventTaskHealthCheckTriggerHandler
Methods:
handlerAfterInsert Handles logic after insert operation.
handlerAfterUpdate Handles logic after update operation.
handlerAfterDelete Handles logic after delete operation.
Description: This trigger handler class contains methods to handle different trigger operations insert update, delete and perform the necessary logic to update the Event Flag based on specified criteria.
Hint
public class EventTaskHealthCheckTriggerHandler
public void handlerAfterInsertList newEventTasks
Logic for after insert operation
Call the updateEventFlags method and pass newEventTasks
public void handlerAfterUpdateList newEventTasks, Map oldEventTasks
Logic for after update operation
Call the updateEventFlags method and pass newEventTasks
Additional logic if needed
public void handlerAfterDeleteList deletedEventTasks
Logic for after delete operation
Call the updateEventFlags method and pass deletedEventTasks with a flag for delete
Additional logic if needed
private void updateEventFlagsList eventTasks
Your existing logic here
Other methods if needed
This breakdown provides a structured approach to creating a trigger and its corresponding trigger handler class with separate methods for different trigger operations. Implement your existing logic within the updateEventFlags method accordingly.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
