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 50% of the tasks are open and the event date is within 7 days, the event will be marked as "Critical" to highlight the urgency of pending tasks.
Step 1: 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 Event_Task__c (after insert, after update, after delete){
if (Trigger.isAfter){
EventTaskHealthCheckTriggerHandler handler = new EventTaskHealthCheckTriggerHandler();
if (Trigger.isInsert){
// Call the handlerAfterInsert method from the handler class
// Pass Trigger.new as the parameter
} else if (Trigger.isUpdate){
// Call the handlerAfterUpdate method from the handler class
// Pass Trigger.new and Trigger.oldMap as parameters
} else if (Trigger.isDelete){
// Call the handlerAfterDelete method from the handler class
// Pass Trigger.old as the parameter
}
}
}
Step 2: 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 handlerAfterInsert(List newEventTasks){
// Logic for after insert operation
// Call the updateEventFlags method and pass newEventTasks
}
public void handlerAfterUpdate(List newEventTasks, Map oldEventTasks){
// Logic for after update operation
// Call the updateEventFlags method and pass newEventTasks
// Additional logic if needed
}
public void handlerAfterDelete(List deletedEventTasks){
// Logic for after delete operation
// Call the updateEventFlags method and pass deletedEventTasks with a flag for delete
// Additional logic if needed
}
private void updateEventFlags(List 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!